I have fired weapons on an FBI gun range. I have done firearms simulation training (FATS) at the FBI, at the Writers Police Academy, and at Tualatin's excellent Threat Dynamics (one of the few places like it open to civilians).
If you don't know about something, do as much reading as you can. Start with the Internet, then maybe progress to textbooks for professionals. (Although there are a few photos in Practical Homicide Investigation I wish I could unsee.) See if you can have a real-life experience.
After that try to have someone who is an expert in the field vet what you write.
For The Night She Disappeared, one of the experts I interviewed was a person who worked on a sheriff's dive team.
For The Girl Who Was Supposed to Die, I had an expert in bioweapons read what I had written about hanta virus and bioweapons. I had done as much research on my own as I could, but we all know that can only take you so far.
I am sure I still make errors. But I try really hard not to.
Everyone who writes books or for movies or TV loves the idea of a safety on a gun. Taking it off ratchets up the suspense. You know you're one step closer to someone dying. But if you write that a character is switching off the safety, do yourself a favor and make sure the gun you are writing about actually has one. This is what I've seen in just the last week. Neither of these guns has a safety.