Starfleet is a multiple-role organisation, centered primarily on exploration (so their primary mission is NOT military), however they ASLO served a military function.
- They are involved in humanitarian relief efforts (US military does this)
- They are involved in tracking down smugglers and interstellar (multi-national) criminals and pirates (US armed services are a good parallel to this, even though the Coast Guard also does this)
- They lead and participate in peacekeeping missions, and are heavily involved in diplomatic missions (UN and US forces do this).
- They act as a defense force for external and internal threats (the very definition of a military organisation).
They ARE a military by any reasonable definition, but their primary mission is one of science and exploration.
They bring military efficiency, techniques and training to scientific endeavors, and serve the same role as UN ilitary forces for the Federation.
It is possible, and likely, that member planets also have their own military organisations, per their rights as sovereign members of the Federation.
I look at Starfleet as analogous to an international Navy, or the UN military, but with a heavy focus on science and exploration rather than the traditional military role.