Reading, reading, reading, reading, CNET forums and others, friends, repair people (fortunately, I didn't need many of them), lots of trial and error, necessity (when I was the only person using a computer in my office), giving lots of thought to problems when they arose and a lot more. I think that everyone has to do it in a way that suits that person's way of dealing with gaining knowledge and dealing with problems. I try to prepare myself ahead of time, but there are always new things to learn. Listen carefully, take notes, make hay from problems. I recently bailed out a PC person, although I have a Mac. She couldn't get her mouse to work but happened to mention that her screen wasn't lighting up, either. I suggested taken the computer's plug out of the wall and leaving it for a few minutes. The computer started up fine after that. I would not have learned that, had I not had a similar problem with my printer, years ago. So I try to apply things both specifically and more globally, when applicable.
Books are great, though I no longer can use much of my favorite, "Sad Macs, Bombs and Other Disasters," because it hasn't been updated for current versions of OS X. The Dummies books are good, and Help functions for various applications can sometimes lead you to the right place. For Macs, the Apple Support online articles can be extremely good. Magazines for your OS may have what you need, and many have online versions. There are forums for many subjects, from the broad ones to those for more specific issues. There are discussion lists also (ongoing, versus responsive only to posted questions).
I haven't used a physical Mac Users Group, but I'm sure that they are good, too, and there must be some for PC users as well.