As the above proves, it is perfectly possible for military organisations to have multiple roles or purpose and AFAIK maritime forces particularly tend to be multi-function rather than being only a war-fighting branch.
Except that with the notable exception of hydrographic and meteorological services, all of the things you described above do, in fact, fall under the purview of naval warfare.
This is the same false equivalence from before. "Militaries can do other things too!" Sure they can, but the
primary purpose of a military is to defend the homeland from its enemies, which means constant vigilance and exercise in preparation for invaders, actual fighting of invaders, and occasionally the pro-active neutralization of would-be invaders. That is the PRIMARY purpose of a Navy.
It is NOT the primary purpose of Starfleet. Canonically, we know that Starfleet's primary purpose is exploration and research, opening diplomatic contact with new Federation worlds, and identifying resources for those member worlds to exploit and enrich themselves. It is very likely that Federation worlds actually take responsibility for their own defense with their own militaries, in which case not only is this role secondary to Starfleet, but they are also secondary participants in any defensive war (the military of the threatened planet is primary and Starfleet would probably have to coordinate with local militias/armies in order to be involved at all).
Congress voted into public law authorizations for use of military force, declarations of war do not require the words "declaration of war" in big bold print across the top of the authorizations.
In every meaningful sense we are currently at war.Nicely worded, this is why nations go to war to protect allies, even if the nation isn't being immediately threatened itself.
Not necessarily disagreeing with you, but the operative word there is "declared."
You can empower your executives to do anything they want; you can give the President the power to assassinate people without trial, nuke entire countries off the map, imprison terrorists, kidnap citizens, intimidate space aliens, club baby seals, fire torpedoes at stormclouds or rape every farm animal in the eastern hemisphere...
But a declaration of war is a LEGISLATIVE action, which declares that it is the law of the land to perform violence against the military forces of another country in order to achieve a specific objective. The legality of those "wars" is accepted only because nobody bothers to challenge it. It's kind of like the cloture rule in the U.S. Senate: by law, a bill can be passed with a simple majority (51 votes) but for the last 20 years or so it's become accepted that you actually need 60 votes because one political party has an unwritten policy to filibuster EVERYTHING. So the Constitution says 51, legal practice says 60.
But like we've seen in Trek, if you think Starfleet isn't the military, your exploration and science divisions end up getting bogged down in never ending military tasks.
Military, in and of itself, isn't a bad thing. It is how it is used by the parent organization.
I agree with this in principle -- it's one of the more interesting things about the Halo Universe, IMO, which does a really good job of diving into the "guns v butter" argument in the face of an existential military threat. The potential for abuse of military power and/or mission creep of the military from being a defensive force to being a POLITICAL force is something that military science fiction doesn't cope with very well, mainly because American writers (and also readers) tend to have a blind spot for the military and always assume The Troops Are The Good Guys. This is one of the very ironic things about Starship Troopers: Heinlein originally wrote it half-
satire, but for fans of the novel took it so seriously that some of the more radical concepts of the book -- like mandatory military service being a requisite for voting rights -- turned up in other works too.
My thought was the Federation insists on a demilitarized Starfleet because, being a multi-planet alliance, they want to remove the temptation for any one planet trying to dominate any of the others through military force. No matter how multi-cultural or diverse Starfleet is, it is STILL predominantly an Earth organization and shaped by Earth traditions and assumptions about the universe; its headquarters, training centers and even its rank structure and self image all derived from Earth. It's entirely likely that the militarization of Starfleet would be immediately followed by a Federation-wide insistence on sweeping limitations of Starfleet's mission scope and authority.
tl;dr; the Federation has the same problem as the United States under the Articles of Confederation: they need a powerful central government (and a strong vehicle for that power) but for historical reasons a powerful central military is politically impossible. So they compromised by creating a strong representative of the central government, but don't grant it the status (or many of the privileges) of a military. Starfleet is the PERFECT organization for that role: they can out-fight many militaries, AND they can handle non-military problems efficiently, which means they can be trusted to be the custodians of the Federation without implicitly threatening anyone's sovereignty.