Thanks to Heisenberg compensators.
https://memory-alpha.fandom.com/wiki/Heisenberg_compensator
The Heisenberg compensator was a component of the transporter system.
The compensator worked around the problems caused by the Heisenberg
Uncertainty Principle, allowing the transporter sensors to compensate
for their inability to determine both the position and momentum of the
target particles to the same degree of accuracy. This ensured the
matter stream remained coherent during transport, and no data was
lost.
As explained in TNG Second Chances:
LAFORGE: Apparently there was a massive energy surge in the distortion field around the planet just at the moment you tried to beam out. The Transporter Chief tried to compensate by initiating a second containment beam.
DATA: An interesting approach. He must have been planning to reintegrate the two patterns in the transport buffer
...
RIKER: How was the second pattern able to maintained its integrity?
LAFORGE: The containment beam must have had the exact same phase differential as the distortion field.

Because they are using two beams instead of one, twice the beams, twice the compensators. Thus, the copy is made. Overcompensating, if you will :)