unless you're in the CG Auxiliary, if you violate regulations in the USCG, you are subject to court martial. It's always military and ready to fly under Naval orders at moment's notice.It's easiest to compare Starfleet to the US Coast Guard which, yes... is military. But also, when at not at war... it's primary function is NOT warfare or military matters. More precisely, Starfleet is like all the US "uniformed services" rolled into one organization. It's the Coast Guard. It's NOAA. It's the Public Health Corps. and yeah, it's the Army and Navy as well. It's a particularly terrible army, but it is one. It's almost as if combat isn't its primary function, and they tend to use repurposed starship personnel from other disciplines when faced with a combat situation...
...almost as if, its primary function is not warfare. Odd.
The US hasn't been in a declared war since 1945, but that does not mean the CG hasn't been involved in conflicts. They don't lock up the ammo and lower the ensign until someone declares war.