I think it’s a combination of proprioception (awareness of where your body is and how it’s moving in time/space), strength (especially core strength), and “feel” (connection/feedback maybe this is proprioception of self plus horse?)
Some of us have a surplus of one or more of these naturally, all can be trained to some degree. Unfortunately proprioception and muscling decreases with age but good training maintains and refines what we have.
I have taught a bunch of adult friends to ride over the years and it’s always surprising to me who gets the feel for it more quickly than others. Runners seem to have a hard time getting good position but do have a decent baseline of balance and core strength. Climbers do well.
And more than once I’ve had people who look so uncomfortable getting their hips open that I know the likelihood they will ever get on again is about nil.