The right isn't guaranteed to the militia, it is a right guaranteed to the People. A well regulated militia is necessary to the security of a free state(comma) this is a statement, the comma separates this idea from the next sentence because they are not the same thing. We as a nation need an army, this is a danger to the people and the government as history has shown us in many cases when a military coup takes place. That is the reason for the right of the people to be armed.
The Bill of Rights does not "give" the people any rights, it just affirms these rights endowed by our creator and limits government from reducing them.
The militia being necessary isn't important because the right isn't for the militia, it is for the people.