Nah, NASA isn't the military. It makes use of military expertise, like how a news network might hire a retired general to comment on military matters, but NASA doesn't wage war....
Yes it does. The U.S. space shuttle was specifically designed to be capable of performing spy missions against the Soviet Union, up to and including the interception of Soviet spy satellites, which would necessarily constitute an act of war. NASA also conducted about two dozen shuttle missions in the 1980s on behalf of the U.S. military, the exact nature of which remains classified (mainly the launch and recovery of reconnaissance and ELINT satellites). Those same missions are now being performed by the X-37B -- a NASA design that has since been militarized for the NRO.
You're thinking that Starfleet is effectively the Federation's navy; that analogy falls apart when you realize the Federation literally HAS a Navy, and probably an army and an Air Force too, and that any combination of these are fully capable of fighting small regional wars all on their own. Starfleet as an organization is just one of many, but it's the one whose PRIMARY goal is exploration, not combat.