Let's say you want to learn a language. In order of increasing usefulness, you can
1. Buy a grammar book and dictionary and read them
2. Buy a text book and work through the examples, and/or use an app
3. Take a course that combines a text book with live in person interaction
4. Move to a foreign country and muddle your way through
In my experience, the last one leads to many awkward and frustrating situations, but has the best results, and fairly quickly. If you move to a place where you truly cannot get by in your native language, you learn to communicate quickly. Meanwhile, all of your everyday interactions, from whats on TV to what you hear on the streets, force you to engage with that language. But if you can't immerse yourself in the language, you're better off learning through and with others and with the aid of materials (a textbook, etc) that are specifically designed for teaching.
Good textbooks will teach the elements of a topic step by step with clear exercises for practice. There might be a limited glossary in the back, but fundamentally they are for incremental teaching and not reference. Good reference books, on the other hand, will organize materials for those already familiar with the language who might need to look up a grammar rule or a word.
So to bring this analogy around, when it comes to DMing the best way is to just start a weekly game, mess up, and try again. Second best might be playing with people who are experienced or new but interested in learning, so you can learn together. Third would be a text specifically designed for instruction (starter set). Last would be trying to learn only from the reference books (core 3 books).