It comes from the combination of hours (years) and miles and situations and weather and road surfaces and conditions and variability between customs “here” and “there” and lighting and attention to all of it.
Before I took the wheel for the first time I had some excellent give-and-take with my father (mostly) and with my mother about why they did “this” instead of “that”; why Dad didn’t always pass the slower driver, and why he sometimes did, and how he managed the vehicle and what he did with his hands, even how he put on his sunglasses when he needed them.
By the time I started learning to operate the pedals it was just a matter of getting the mechanics of operating the clutch, the shift, the brake-and-gas-pedal shuffle, the high-beam switch on the floor, and actually moving the wheel and guiding where we went.
It still comes down to paying attention. I ride with some people sometimes (once is too many times!) who obviously manage mostly because other people pay attention to them, because they’re not doing it themselves!