The way the amendment reads is that the people must be armed in order to form militias to ensure the states stay free; it does not tie the requirement of arms to a militia.
This is backed up by many statements by the founding fathers who state one of the core components to keeping America free from a tyrannical government is an armed citizenship willing to act, compared to Europe, where the citizenship is disarmed.