The need was to avoid the European experience. During the war fought by the colonies against Britain, the King controlled British military, but the framers wanted to move away from that.
When they wrote the Constitution, framers separated the responsibilities for the military, placing them firmly in civilian hands: in the President, as the “Commander in Chief of the Army and Navy" (Art II, Sect. 2) and in the Congress since it has the power to declare war and to make the rules for governing the military.