The phrase "well-regulated" is an idiom that means something like "working as expected, calibrated correctly, normal, regular". You can't interpret an idiom literally based solely on the words that it's made from - idioms have their own independent meaning.
The following source gives examples from the Oxford English Dictionary of how the idiom was used from 1709 through 1894, demonstrating how the idiom 'well-regulated' has meaning beyond 'regulations' i.e. laws.
https://www.constitution.org/cons/wellregu.htm
> 1709: "If a liberal Education has formed in us well-regulated Appetites and worthy Inclinations."
> 1714: "The practice of all well-regulated courts of justice in the world."
> 1812: "The equation of time ... is the adjustment of the difference of time as shown by a well-regulated clock and a true sun dial."
> 1848: "A remissness for which I am sure every well-regulated person will blame the Mayor."
> 1862: "It appeared to her well-regulated mind, like a clandestine proceeding."
> 1894: "The newspaper, a never wanting adjunct to every well-regulated American embryo city."
The sense of the term above is something like 'normal', 'well-ordered', 'regular'. Indeed the word 'regular' also shares the same origin as the word 'regulations', yet its common meanings are unrelated to the concept of regulations.
Parsing the 2nd Amendment, the US Supreme Court wrote that "the adjective “well-regulated” implies nothing more than the imposition of proper discipline and training", and elaborated (quoting another scholar, Thomas Cooley):
> The meaning of the provision undoubtedly is, that the people, from whom the militia must be taken, shall have the right to keep and bear arms; and they need no permission or regulation of law for the purpose. But this enables government to have a well-regulated militia; for to bear arms implies something more than the mere keeping; it implies the learning to handle and use them in a way that makes those who keep them ready for their efficient use; in other words, it implies the right to meet for voluntary discipline in arms, observing in doing so the laws of public order.”
https://supreme.justia.com/cases/federal/us/554/570/#tab-opi...
The phrase "a well-regulated militia" in this context consequently means a militia that's learned, proficient, and effective in firearm use. In any case, what we're discussing is the preface of the amendment, which announces a purpose for the amendment and does not limit it. As the court wrote:
> The Second Amendment is naturally divided into two
parts: its prefatory clause and its operative clause. The
former does not limit the latter grammatically, but rather
announces a purpose. The Amendment could be rephrased, “Because a well regulated Militia is necessary to
the security of a free State, the right of the people to keep and bear Arms shall not be infringed.”