Anyone else having deja vu here? Pretty sure there was a "Starfleet is/is not military" thread a while back
Also, Section 31 is considered evil because it is outside of the law. There is no check upon its combat abilities, and the fact that they are trying to make a preemptive war and violate the law makes them villainous.
The military role is balanced with the exploration role and some times they do both. It can be a both/and scenario not an either/or situation.
But, there is a lot of on screen evidence for Starfleet being a military organization, even if it isn't militaristic or imperialistic in its approach (In TOS, the Klingons were often the opposite of that). Kirk even identifies as a "soldier" to Kor, and doesn't argue with Chang when he calls him a "warrior."
For every instance of Picard objecting to the "military" label there are examples of other captains doing differently. Also, despite his protestations, Starfleet has a ranks, weapons training and if their rules are violated, then there is a court martial-which means "military court." The Federation also has no other organization by which is can defend itself, or its allies, in times of war.
I'm not saying that Starfleet's primary job is war, but that it has a multifaceted mission, one that has similarities to the modern US Navy. It isn't dystopian to protect oneself and allies.
Yeah, I think people have a tendency to look for analogues of what Starfleet is, in our own time. This doesn't work (since the Federation is not our society). The closest thing that exists to it right now is NASA, and this comparison was made even more explicit in ENT, which deliberately referenced the NASA culture ("The Right Stuff", "From Earth to the Moon", "Apollo 13", etc). The next major influence, is the US Navy; with many starships even bearing the name of illustrious WW2 vessels - Enterprise, Essex, Intrepid, Yorktown, Lexington. Maybe a few elements of US Air Force test-pilot culture are thrown in too, but in ENT mainly.
It is both a scientific/educational institution, and also as a secondary role, the defense force of the United Federation of Planets - an entirely voluntary union of alien societies, which exists to render mutual aid. Basically Pike's word's in the new movie "Peacekeeping and Humanitarian Armada", is more or less spot-on, as far as it's military role is concerned - it is not meant to be the interventionist military of an imperial democracy, but something closer to UN Peacekeepers. But, discounting it's military role, clearly, it has deep roots in civilian space agencies - ENT paints it as more or less a direct extension of them.
The writers also specifically point out in Star Trek Eleven, through Christopher Pike, that the Federation is " a peacekeeping and humanitarian armada." No mention of exploration there.
The misconception that Starfleet is 'primarily' anything, may come from people trying too hard to find an analogue for it today. Starfleet is both. We have seen enough to know that neither takes priority. They send entire front-line starships, such as the Constitution-class Enterprise, on deep space probes, incredibly long missions of scientific exploration - as if it's their primary design. They commission entire classes of starship as moving labs (the Intrepid class) just for deep space scientific observations (a direct analogue for Viking, Mariner, Apollo, Hubble, etc). If you want to see this in military terms - so did the 18th century British Royal Navy; because new navigational science, new botany, charts, new colonies and new trading partners were essential. But I don't think we can see Starfleet even in those expansionist terms; they literally are an extension of civilian scientific space agencies like NASA and the ESA. The missions these ships are sent on are explicitly talked about on screen as being for the same reasons that NASA sends out Galileo/Cassini/Magellan. They are pure exploration attempts.
Clearly Starfleet trains it's crews both mentally and physically, for the unwelcome advent of war. But it also clearly functions as a NASA type space agency, investigating the fringes of science in the cosmos - for it's own sake, to further science, and to improve our understanding of the universe. Like the old wisdom literature of the ancient world, Star Trek argues for a society where the 'just king' lives in peace, but is always ready for war. Starfleet exists to render mutual aid and explore the cosmos, finding new science to benefit the people of the democratic Federation. But it is also ready for other eventualities, and even humanitarian missions may require fighting-fit crews, ready to climb cave systems, or run marathon distances. It is recognized that military personal, such as Commodore Decker, may turn rogue, but they are offered help and medical care if possible, not executed with prejudice.
If you want an analogue of the Federation, on-screen evidence seems to paint it as something more like the United Nations or European Union - not a close federal union like the United States - as the individual planets seem to almost exist as foreign societies from one another; the common aid they render and mutual front presented against the Klingons, etc, seems more like an alliance than a Nation-State. And Starfleet represents the NASA astronaut corps, trained at Starfleet Academy to be like the Mercury 7 astronauts, or the Apollo crews - but given the additional duties of a UN Peacekeeper, Rescue Worker, Aid Worker, and US Navy officers.