America had no standing army, and many of the founders did not want one. Hence, the need for a militia.
It’s a prefatory clause and an operative clause. The first explains the purpose, the second gives the rule. So you can certainly argue that the rule must be considered in the context of the purpose.
But that still doesn’t get you where you’re going. Because personal firearms ownership certainly facilitates raising a militia if you need one.
I wonder if that means the lack in the US of official citizen militias dependent on private firearm ownership could be considered unconstitutional.
IIRC, the National Guard is reckoned to be the militia, but that seems a little like BS to me. It seems pretty much to be a de-facto component of the federal military, complete with rotations to fight foreign wars, etc.