A member of a well regulated state Militia does not necessarily have the right to keep and bear arms.
The governor or commander could issue an order to those under his command to disarm. Congress may lawfully remove it by taking command of the state Militia and issuing an order to disarm. See I.8.15 & I.8.16.
How does the Second Amendment prevent that?
It doesn't and never has. The right shall not be infringed by the federal government.
Why would a governor or commander issue such an order? Has any governor or commander ever done so in the history of the United States?
"Congress may lawfully remove it by taking command of the state Militia and issuing an order to disarm. See I.8.15 & I.8.16."
That is what the second amendment was designed to protect against.