Interesting question.
Trial and error, plus the 'net, plus--very early on--some coaching from my dad. He bought us one of the first IBM PCs... if I recall correctly, it was an 8088 that ran at a blazing 3 mhz, had a monochrome text-only display, two (two!) 5 1/4" floppy drives, no hard drive, dot-matrix printer...
During my teenage years in the 80s I wrote weird little music programs in BASIC and uploaded them to local BBSs over our 300bps Hayes Smartmodem. (I wonder if those programs ever got out of Poughkeepsie.)
A few years back I built myself a PC. Just did it again recently. I'm tickled at how much that tends to impress people at work. I'm a tech writer, former English major, and female. Whenever I start a new contract it seems the people around me aren't really expecting me to be a geek, and so they're surprised. On the tech writer listserv I subscribe to, I sometimes see posts from a few people who don't have much tech savvy, and what they do have, they got from training. I think they're at a huge disadvantage. If you can't continually teach yourself stuff--and have the curiosity to do so--it's hard to keep up.