Correct. The U.S. Constitution says "the militia". But it is certainly referring to a state militia. What other kind of militia has its officers appointed by each state?
"Likewise the 2nd Amendment - which refers to the militia, not state militia."
Correct. The second amendment says "well regulated militia". But it is certainly referring to a well regulated state militia. What other kind of militia is well regulated (organized, trained, armed, and accoutered)?
Under the Militia Act of 1792, Congress organized a state militia. The Militia Act was not referring to a federal militia nor a neighborhood militia. It was referring to a state militia with officers appointed by the state.
Likewise for the Militia Act of 1792. It has the states appoint officers, and has states do other tasks pursuant to the militia, but does not separate out militiaS as multiple independent entities. What the Act organizes is a federal organization pursuant to explicitly delegated Constitutional power, with portions thereof managed (but not owned per se) at state level.
The officers appointed by a state preside over militia members resident of that state. Both, however, serve in "the militia" (singular), which is a federal organization with the President at its helm.
If, as you contend, it was all about "state militias", then Congress would not have been granted the power to organize the aggregate thereof, and would not have had the power to pass a federal "Militia Act" which legislated the organization in great detail (right down to the minimum number of bullets each member must have). The states are granted the power to assign officers, but it is done as a whole under the organization of Congress and direction of the President.