Picard (in Insurrection): "Can anyone remember when we used to be explorers?"Starfleet's flagship did not participate in the Dominion War. It continued to pursue exploration missions throughout that conflict, as referenced in Star Trek: Insurrection.
The movie Insurrection show us a few days of the ship's activities six months prior to the end of the Dominion War, what the Enterprise was doing over the course of the war is unknown.
Also, the Enterprise D wasn't Starfleet's flagship, the Enterprise D was the flagship of the Federation. Not the same thing.
The Federation needs a military to fight it's never ending series of wars.Who says the Federation has to have a military?
As previously covered, Costa Rica does have a (admittedly small) military, they just don't refer to it using the term military.There are real world nations on planet Earth today that do not have a military (Costa Rica, for example).
Costa Rica's military are "special intervention units," the way Japan's military are "special civil servants."