Which protects the right of the military to own weapons.
No it doesn't. The first part of the clause merely states the primary motivation for, the explicit natural right that is established in the last half of the sentence. It doesn't condition that right.
In the 18th century, service in the militia was compulsory. And were considered a threat to the control of the central state and the national/Imperial Army. There was great opposition to a standing army as well at the founding because standing army often lead to centralization of the state, and reduction of freedom.
There was also for them in recent historical times, instances of the centralized state trying to disarm the local populace so as to enforce the degradation of natural rights and representative government. King James II, tried to disarm the militias to prevent them from rising up to support William of Orange. In 1774 when enforcing the Intolerable Acts, the British Army sought to seize weapons and disarm the surrounding peoples, so as to enable their suppression of natural rights and representative government. It was one of these raids in 1775, that sparked the Revolutionary War.
The Bill of Rights is so composed as a response to, and a protection against, the impositions and degradations rights imposed on the colonists at the hands of an oppressive imperial regime. That is why there are protections against search and seizure, quartering etc. The right to keep and bear arms is likewise present because the British attempted to forcibly disarm the populace, so they couldn't resist the degradations in other rights, freedoms and democratic rule.
There is absolutely no purpose behind, and no historical basis for, such an amendment (in RL Constitution) existing to protect "the right of the military" to arm itself when such already existed under the grant of powers to Congress to raise and equip a military force, as well as the necessary and proper clause. The presence of such language amongst the "bill of rights", which was composed as a list of natural rights, and many of which were infringed by the British during the lead up to and during the Revolutionary War, only exists (like all other sections in the Article) as the government's recognition of the natural rights of the people and the government's stated desire to protect the same.