Diagram the sentence, just like you learned in English class:
The subject is the right of the people to keep and bear arms. In this subject, "of the people" is a noun phrase that specifies the right to which the predicate applies. Similarly, "to keep and bear arms" is an infinitive phrase that again narrows the subject under discussion, leading to a final definition of the subject under discussion - the predicate applies not to all rights, only to rights of the people, and among all the rights held by people, the predicate applies only to the right to keep and bear arms. The infinitive phrase "to keep and bear arms" specifies two rights of the people: the right to keep arms, and the right to bear arms. The wording does not create each right, rather the preexistence of those rights is assumed.
The predicate is in the simple future tense, negated, and provides the strongest possible restriction on the action "to infringe" when applied to the subject. "Shall not be infringed" is stronger and broader than the First Amendment limitation of "Congress shall make no law," applying to all three branches of the federal government rather than just the legislative branch, and cannot be made stronger with any choice of words.
As for the Militia Clause: "a well regulated militia, being necessary to the security of a free state," this clause contains a subject A well regulated militia and a gerund phrase being necessary to the security of a free state. The wording does not include any hint that this militia clause is intended to act as a restrictive clause, one that could narrow the meaning of an earlier or later subject. Rather, the militia clause is a nonrestrictive relative clause, set off by commas, that is intended to add information without modifying the subject of the main clause.
The bottom line: the right of the people to keep and bear arms is assumed by the wording to be a preexisting and unconditional right. The predicate shall not be infringed applies to that right without any limitation. Thus the right of the people to keep arms shall not be infringed by any branch of the federal government, and the right of the people to bear arms shall not be infringed by any branch of the federal government. Neither the subject nor the predicate is modified by the militia clause. The militia clause A well regulated militia, being necessary to the security of a free state provides added information on the importance of the right under discussion but does not in any way restrict or limit that right.
/End pedantic monologue.
Shall not be infringed by any form of government