Starfleets mission statement is to seek out life, not to protect and serve. Hence it isn't a military.
It only does the later when absolutely necessary, and seeks out all possibles that would lead to avoiding it.
It's also been suggested (or at least alluded to), on all the shows, that most officers only have basic combat training and only have to learn combat tactics once they reach the higher echelons of command.
This to me does not say "military".
Also, lots of places outside militaries have hierarchical command structures.
I think the biggest mistake was it took five series to get the MACOS. There should have been something similar in place long ago--to avoid confusion.
Yeh there was always the question if there were "starfleet marines", speculation came from Cl West in TUC.
Were those guys in black combat suits on the ground during the klingon war from this branch or just starfleet security?