On the military issue: i always liked the way, Starfleet is organized in FASA's stuff, there is (among others) a Exporation Command, which command ships of exploration and a Military Command, which is in charge of straight military operations, which in peacetime mainly is defence of the Federation.
Going with the view of the"Age of Sail" navy, those also had massive Warfleets purely to protect their interest in a military way. While ships like Endavour
were conducting scientific missions, the Royal Navy had many ships of the line like Victory
and also smaller vessels dedicated to the military role in waiting for the need for an military engagement.
After all, the UFP neighbours, among others, the Klingon and Romulan Empires. Those borders clearly need a standing guard.