If I’m not mistaken, a “militia” was understood to be an ad hoc, non-standing armed group, supplied by the resources of its members. The amendment was added so that if a militia were ever needed (again), it could be formed, because the pool of potential militia members had their own firearms. Laws limiting citizen access to firearms would hobble any new militia.
Given that armies at the time were only recently becoming “standing” (permanent) armies, and the U.S. didn’t really have one, their best option for making war was militias. They were acutely aware that the revolution began that way, and only later developed an actual (organized, separately supplied, long-term) army.
But very quickly, the U.S. developed permanent armed forces and never had to rely on militias again. At that point the 2nd amendment really should have been obsolete.
That phrase doesn’t mean what you think it means.