Seeming occassional incompetence of the Starfleet security people is just a TV thing. Writers and actors are not experts of military tactics. It is not like the supposed super warriors like Klingons and Jem'Hadar appear much more competent.
I bet there are some former military guys who would help them even for free. I hope they will use some better military tactics in all future Trek. This is not the 60s.