By doing it. I'm not even really sure how I picked it up... It just sort of came to me some four or five years deep on programming; nearly three and a half decades ago.
I do know that typing in BASIC and Assembly language games from source code out of magazines did a LOT to help with that. Sooner or later you HAVE to keep your eyes on the source and not your hands or the screen or it takes you forever as you'll keep losing your place.
That's something I think todays up and coming programmers miss out on; everything is handed to them on a silver platter and they don't get the joy of getting a paper magazine, typing in the entire program themselves from the source, and running it. There was a sense of accomplishment to it actually running even if you weren't the one who wrote the program.
Many of us "greybeards" also learned a great deal about how programs worked from having to type in that code, and putting our own changes/improvements into them. Hence why for some of us old-timers out there we still refer to the "Big Yellow Book" -- aka "BASIC computer games" by David K. Ahl -- with reverence.
en.wikipedia.org/wiki/BASIC_Computer_Games
You look around you can find PDF's of a lot of such books at places like Bombjack's Commodore archive.