There's a trade off between stability and mobility, and evolutionarily we've gone down the mobility route, which is a good thing for us humans, a tree is stable but ...
A passenger plane has a large wing span making it very stable, but it turns slowly. Military fighter jets looking for greater mobility opted for smaller wings, but during their development they hit a wall where the increased instability meant they became unsafe to fly.
A solution was eventually found with the scaling down of the size of computers so that an on-board computer could manage the fine control to keep the plane stable whilst the pilot only has to deal with the direction they wish to fly in. Contrast the classic WW2 Spitfire which had a wingspan longer than the length of its fuselage, to the modern Euro Fighter whose wing span is shorter than its fuselage. All commercial passenger planes now use the same technology for added safety and to give the pilot a break (auto-pilot).
This on-board computer is known as the Fly-by-Wire system in the aerospace industry (I grew up around planes, my father was in the RAF and chairman of Cosford air museum, hence this analogy), and we have our own equivalent in the cerebellum at the lower back of the brain. Whilst you go about your daily business, for the most part you're not thinking of not falling over, only the movements you wish to make to interface with your outer environment. Actually, if you want to move freely you're much better off thinking in terms of spacial awareness rather than specifics of your anatomy.
The point of this is to recognise that you're an unstable structure and your posture/poise is in itself a movement activity, always adjusting and readjusting to find the support provided by gravity. It's something you let happen much as you let yourself be breathed.
We tend to struggle more with this when we're sat, because the ankle, knee and (partially) hip joints have been taken out of the equation. You've become more stable, which often encourages more rigidity in the spine and torso, especially if you're not familiar with what free sitting feels like to begin with. As mentioned in this previous blog on sitting, sitting and standing are essentially the same thing for your spine, you just stand on your sit bones on the underside of your pelvis.
What we need to become aware of is the natural mobility of the spine as it adjusts and readjusts through the human Fly-by-Wire system. With that in mind we're going to do an exercise/exploration.
To start with you'll need to find your sit-bones and some sense of being "stood" on them with reasonable poise/posture. The best way to refind your poise when seated is thorough movement rather than trying to find a correct shape. Literally walk your sit-bones back and forth across the chair surface and become engaged with the space around you, especially the space above and behind you that you no doubt routinely ignore. Let your posture be the outer manifestation of your mental engagement with your external environment and the support being offered by gravity and your seat coming up underneath you. If you're on a chair that swivels it can be hard to walk back and forth on your sit-bones, but you can still get good results shifting your weight between your sit-bones, rocking the pelvis from side to side.
We'll do this exploration with the eyes closed to help destabilise you again (our eyes are part of the feedback system for balance) to make it easier to make observations since you're more stable when sat.
Once you have a good sense of being "stood" on your sit bones I want you to sway from side-to-side allowing the whole spine to bend, and the head to naturally fall in the direction you're leaning. It can also be nice to generate a snake like movement along the spine. The next step is to stop intentionally moving, but to not try to stop moving. What you'll hopefully observe is your own Fly-by-Wire system taking over and look for more equilibrium. Although the swaying will be damped down quickly, you'll observe that you're still being moved, even if it's subtle. Sometimes things settle till it reaches what I'll call a still-point, where the skeleton is aligned well enough that the movement has become imperceptible. If this goes on for too long I'd start to question whether you've simply become rigid. If in doubt, set the pendulum swinging again by intentionally generating a little movement.
You'll soon realise that you never need to sit rigidly upright again to have "good posture". You are always free to move and be moved.