"Write what you know," may be the one piece of writing advice that the most people - regardless of whether they're writers or not - know about. Whether it's good advice or not is complicated.
It is good on the level of understanding that, for a number of things, someone will know better than you, so you don't want to insult their experience. You might not be prepared to delve deep into army life if you're a lifelong civilian writing out of pro-war or anti-war feelings. Don't write about how young people are dumb brutes only interested in sexing and drugging and Candy Crush if you never talk to anyone under 50. The makers of Forrest Gump surely pissed off members of Students for a Democratic Society when they portrayed the SDS as being all about posturing and girlfriend abuse, although this group wasn't numerous enough to put a dent in its box office.
On the other hand, if you have an urge to write about a subject, that should be followed. Why? Because it's largely work you do with your mind. And your mind, your imagination will go where it goes. Trying to cut it off is making poor use, non-use, of your best tool.
Tom Cobb used to tell us, "Know what you write about." Which is good advice. Educating yourself as to the subject you want to explore is good practice, and potentially can be fun. Of course what kind and how much research you do depends on what you want to do.
With that in mind, here's some research I've been doing.