Picard stated that SF is not a military organization.
Its more along the lines of 'jack of all trades'.
While one of its functions is to defend the Federation, it has a much bigger emphasis is on exploration/discovery/research/science/diplomacy.
The writers merely presented in a more pseudo-military fashion though because its related in a way to it (but its not that).
And people today will often mistake SF as a military because it bears a resemblance to what we have today (even though its not the same thing).
I will agree though that more common sense should have been applied, but that much was down to writer stupidity who had little idea on how to manage such a universe properly.
Add to it that as time went by, SF was portrayed in a more military fashion than it was earlier (the show de-evolved more into 'today in space').