Except "being necessary ... militia ..." is not an operative clause, it is a prefatory clause. The operative clause is "the right of the people ... shall not be infringed."
Prefatory clauses are used to give some reasoning or approach, but not a binding condition.
You could rearrange the second amendment in today's parlance as such:
"The Right of the People to keep and bear arms shall not be infringed for reasons including, but not limited to, that a functioning and ready militia is necessary to the security of a free state."