In the costly war against the Romulans, the Federation had to sign a dumb "Build no Cloaking Tech" treaty just to get peace.
As for the Klingons, we know that it was a fairly bloody war.
As for the Tzenkethi, they weren't mentioned in much detial.
The Cardassians were a border skirmish that did involve people, but it wasn't something we couldn't handle because the Cardassians were behind technologically.
The Dominion was very bloody and costly, WW2 scale.
As for the Borg, we got lucky / close called too many times. A lot of it "Plot Force" driven
Some thoughts on the wars:
The war with the Romulans happened before the Federation. The cloaking device treaty not only maintained peace for half a century but in that time the Romulans stopped expanding while the UFP ballooned. Who needs a cloak when you're getting everything you want? And the moment the Romulans reneg, the Feds have a phase-cloak lined up. Thank you, Science.
The Klingons are a much older civilization with and additional head start of Hurq technology. They're also an entire civilization dedicated to battle and they don't mind mind-boggling amounts of loss to Klingon health, happiness, and life. They're also slavers, corrupt at nearly every level, and genocidal. Still the Federation comes out on top. And it will do so even more with time as the Klingons fall behind technologically.
The Tzenkethi weren't mentioned in much detail but they lost and are barely mentioned in interstellar affairs.
The Cardassians lost millions despite their centuries of military rule. And they became a third rate power in the war with he Klingons, who, again, are now our allies, thanks not to our military might but our defense of them against the Romulans at Narendra III.
The Dominion is a 2000-year old expansionist empire. Thems the breaks. We're lucky the Organians don't decide to heed the lesser demons of their nature. Still the the Alliance managed to wrestle victory.
The Borg we did get lucky on but it was also luck that introduced them to us via Q. Maybe the self-proclaimed keepers of the universe allowed for a little of that after they made the intro. Still the Federation was more ready for them in FC than they were in BoBW, and it was thanks to R&D, not some massive shift Empress Georgiou would have been proud of.
https://en.wikipedia.org/wiki/List_of_wars_involving_the_United_States
The US has got into plenty of wars in our history.
Most of those "Aggressive Fly By's have been with Russia / China as of late.
Right, we're [messing] with each other due to geopolitical and economic concerns that are not at all helped by us [messing] with each other. If one of those incidents goes badly, suddenly we're in an exponentially tenser environment that easily could lead to the bloodiest or perhaps last war. So much for Star Trek.
That's why going to war shouldn't be done so trivially. And maintenance, training, upkeep is vital IMO.
Again, it's not an either/or. Ro had just gotten back from advanced tactical training in "Preemptive Strike." I imagine she's a future Navy SEAL or something.
What we do is a mix of intidmidation factor, backing up our claims, securing our interests, and helping those when able to.
A vast military is meant for "Many Things", not just blowing up stuff. That's a overly simplistic view of the military.
I'm aware of that, but I'm also suspicious of how much oversight our Central Command gets. The Pentagon failed its long-overdue and staggeringly expensive audit recently. This after already wasting $125B no-one knows where. This after leading us into a multi-trillion-dollar imperial war under false pretenses in Gulf War II. This after previously and to this day sinking trillions into Afghanistan. (And the region is bad as ever, and we can't be bothered to help refugees fleeing the apocalypse.) I say this not to commence a political discussion but to make the point that all these ungodly sums of money go somewhere. They profit people and lobbies, and I think we need to have a far more frank discussion about that, in all its complexity, under the light of day, very unlike the discussions we have had time and again by the ruling class wheeling out the voodoo specter of National Security whenever they want to spend 54 cents on your every tax dollar. That doesn't just go away when there isn't an enemy to fight. That monster needs to be fed. And that may be the natural order of things, if we're to remember the Romulan Commander's lament in "Balance of Terror." The only way to win is not to play. And for that you need the fleet to be playing something else when it's not in war mode. And for that to be what it does most and primarily -- maybe that's why Starfleet isn't a military organization. And it's probably why the Federation will not only out-evolve the Klingons, but it's why it's already the most powerful entity in half the galaxy that everyone wants to do business with and looks to for law, culture, and leadership.