And the answer was this:
Because most of the things that threaten the Federation DO NOT have military solutions.
Starfleet are professional problem solvers who consider military threats to be just one of MANY problems they have to deal with. From what we've seen, they invariably approach combat situations almost like complex engineering problems:
CMDR: That alien ship is attacking the colony from orbit. We need to stop them.
SCI: They're using gravitic disruptor weapons. We can probably block their emissions by extending our deflector shields around the station and modulating a subharomic band to deflect the signals.
CMDR: Great. That solves the civilian problem. What about the attackers?
SCI: Their ship has three warp nacelles and a maximum velocity of warp seven. I've identified six vulnerable points in their plasma distribution grid where a focussed tachyon pulse could scram their main reactor and force a shutdown. But we'll have to take down their shields first.
TAC: I've set the phasers to match their shield frequencies. We can take down their shields with one shot.
CMDR: Sounds like a plan. Execute!"
<Shields extend, phasers fire, [tech] beam shoots from the deflector and the alien ship shuts down>
CMDR: Great work, team! Alright, let's open hailing frequencies and figure out who the fuck these guys are and what their beef is with the colony...
And that's fucking TUESDAY AFTERNOON with these people. A
real crisis that challenges Starfleet's expertise involves planet-sized godlike entities with incomprehensible motivations, carting around enough destructive power to ACCIDENTALLY vaporize entire solar systems, on a level of technology or otherworldly scariness so vast that any attempt at a military intervention would be met with either laughter, a yawn, or a flick of a finger and instant death.
I strongly disagree. Alot of the real EXISTENTIAL threats to the Federation are posed by things that are threatening not by virtue of their belligerence or political disagreements, but because just by virtue of their PRESENCE. Most of these things (e.g. V'ger, the Whale Probe, the Crystaline Entity) have no belligerent intentions whatsoever and cannot really even be communicated with, which means that conventional military reasoning is completely useless; the logic of deterrence, interception, sovereignty, political autonomy, ALL of those become irrelevant.
Thinking the MILITARY would be the best tool for those jobs is beyond absurd. It would be like the United States being threatened by the aftermath of Zeus' bachelor party (he turned the state of liberty into a real woman and then had sex with her in the middle of Central Park, causing massive property damage to the surrounding neighborhoods) and the U.S. Navy trying to solve that problem with an aircraft carrier. Like... really? What are you gonna do, shoot holes in his thunder condoms?
I don't think the Federation has or NEEDS military forces, not at the tech level we've been shown. It actually appears that the Federation is advanced enough that the business of warfare could be -- and probably is -- completely automated. If even the deeply flawed EP-607 is capable of successfully engaging starships in orbit, I would imagine Federation technology is at least as effective (especially since they probably captured the designs for the EP607 after "Arsenal of Freedom."
They DID, in "Enterprise" with the development of "MACO."
But Star Trek plays to American audience where military fetishism is basically a national passtime, and the fanbase couldn't accept this distinction. This is why we now have the argument being made "Earth Starfleet is COMPLETELY DIFFERENT from the Federation Starfleet!" followed by "Earth Stafleet is totally the military too because chicken wings!"
Of all of of mainstream science fiction, Star Trek is one of the very few major franchises that goes out of its way to depict a non-military protagonist with government sponsorship. Alot of the fans like Star Trek enough to follow it but still can't buy that basic premise. Partially because it's a rather silly idea from the get-go, but mostly because American viewers are deeply uncomfortable with a version of the future in which "the military" is not a force for good.
Meanwhile, I'm predicting that some time in the future, in a bid to remain relevant to modern audiences, some enterprising Trek writer will retcon Starfleet as the 24th century equivalent of SpaceX.