In TWOK, Carol Marcus reminds David that Starfleet has kept the peace for over one hundred years. So, keeping the peace is one of its duties. You need an armed force to keep the peace, so by definition, Starfleet is a military organization of some kind.
It could also be that Starfleet only mobilizes militarily at times of conflict. At least before the Cold War, there was a long tradition in the United States of keeping a small military during peacetime, and increasing and mobilizing it only for imminent war. Marcus was obviously trying to increase the military posture of Starfleet based on what he perceived as a real threat even in a time of peace. That he has a model of the Vengeance on open display in his office was a symbol that the extent of the military role of Starfleet must've been an open question at many levels in the post-Vulcan Federation.
Scotty has to know that part of the price of joining Starfleet and getting to explore the galaxy is that you may be called into duty to defend the Federation. It's not like he doesn't know the ship has phasers and photon torpedoes and may find itself in armed combat. He only objects to Marcus's photon torpedoes and their mission. I think what Scotty objected to was the idea of using Starfleet as an offensive or pre-emptive force. The ethics of killing Harrison aside, it wouldn't take a scholar to know that firing 72 missiles at Kronos would start a war. Starting wars is probably not in Starfleet's mission statement.