I fell into a a full load of AP/Honors in the 10th grade and HAD to study to catch up after reading on my own in the back of the class. I had chemistry, physics, precalc and geometry, english, and history. All honors or AP and with a small group of kids who had been together since elementary school. With dozens of problems in the STEM classes per day and hundreds of pages of reading and writing assignments each week.
It was fun but it was also a shock.
The big thing was having a weekly planner, a weekly plan, and time to study each night.
The summer before I went to college I decided I would test out of some classes - and spent that summer working my way through textbooks. And successfully tested out.
My last semester in school I took 24 hours with just one B. They let me do that because the semester before that I took 21 hours and got As.
In college, the hardest class I took was from a Caltech visiting professor. He was absolutely ruthless. He spent the first class putting up what our schedule should be and how to fit in the amount of study he would require. I realized then that I was not anywhere near my potential in how much I could work.
When I moved over to the math department, my adviser there gave me a book on how to study. And they required me to take a weekend course on being organized. This helped even more.
How to develop it at an earlier age if the school is not challenging?
The only way is to pick a subject the child likes, set goals, then work on it every night as if it were a college level course with hard deadlines. I know that a number of metro areas have Chinese or Russian weekend courses and there are some math courses via math clubs that do this. Or, you could pick a dead language. Or an online course.