If I remember my Science Of Star Trek manuals correctly[1], it doesn't.
The de-materialising person has their original matter engulfed in a sub-space field, dragged (via a 'storage drum', in the case of dematerialising from a transporter pad) into a stream of particles that travel through subspace towards the destination and (again via a storage drum, where the destination is (also?) a pad) collated and re-cohered at the destination in the original shape[2]. The stream contains matter and its associated energies (in fact, I think it's been used to transport energy-only creatures as well), thus the reconstruction is identical in consciousness[3].
You can get a good range for pad2pad transportations, because you use the capabilities of
each pad (that 'storage drum' - around which the 'transporter pattern matrix', or whatever they're calling it in any given iteration of the series, whirls while it's being de-cohered for sending or readied for re-cohering after receicing) to ensure a clean de-materialising and re-materialising process. To overcome the problems of Heisenberg's Uncertainty Principle, a vital part of the equipment is the Heisenberg Compensator. (IIRC, when asked by an enquiring fan
how it worked, the producer/writer involved replied "Very well, thank you...") Early iterations (Enterprise. NX-01's show) may not have had this at first, or perhaps a lesser version. It was a big thing when it became man-rated, but still mostly used only at times of great need.
For trips from pad to non-pad or non-pad to pad, the capabilities of the transporters involve projecting the (de-/re-)materialising fields to the remote location, which means a reduced capability of range (also the single drum/HC involved means more work needs doing to keep/restore coherence. It's also possible to do site-to-site (both non-pad) transportations, but that really involves a site-to-pad (or at least the drum container) then rebroadcasting back out to the destination. That's complex. For outward journeys, I always
used to imagine that the firing of the stream through sub-space was done so as to degrade from this path at
just the right point (for each and every element of the stream) so as to enter normality in the intended configuration, but that's like a totally insane version of the
guy toting a huge pile of bricks (and he dropped one!), and I'm sure something more 'sensible' involving a projected reconstruction field is involved (and would more easily explain inwards journeys).
With the pattern in the drum, we've seen that there are some 'basic' things that can be done with the transporter pattern. There's a 'biological filter' that does the job of plucking out undesired pathogens (
most of the time, there are times when this has failed, mostly due to the nasty stuff being of a novel type) from the stream, meaning that a returning Away-Team member is not bringing back anything undesirable. This can be retasked, as well as enhanced to remove a previously unknown threat, once the threat has been suitably analysed. Also there's the capability to detect powering-up weaponry (or even the presence of unauthorised phasers) within the stream and remove/modify the constituents of the stream that are involved so as to disable these (or even remove the weapons entirely, but TOS liked powering them down the most, IIRC). But that's got to be
really complicated, in actuality, given how a 3D configuration of every source particle (not counting the additional momentums/etc that you'd be conveying) is squeezed into a 1D stream, all going round in a blender-with-attitude.
And when a pattern has degraded/lost mass or something and the systems reconstitute a traveller as a
juvenile version of themselves,
that's not a simple thing, either, and nor is its reversal once the plot allows this technical feat to be accomplished properly... But far better than emerging without limbs, organs or other problems, so with that kind of power behind the stream-management system no wonder everyone (well, except for people like Howlin' Mad Barclay) tends to trust their workings so implicitly.
Oh yeah, and there's been long-term continual recycling of streams to keep people 'in transportation' (Scotty's appearance in TNG, although his companion's pattern did not survive long enough, but that it was possible at all was a typical Scotty-miracle), and then there was the creation of 'Thomas' Riker (the matter must have been doubled), and ever since TOS there's been transportation between realities (Mirror Mirror, and TNG/etc representations). Compared to that the extension of Transporter Technology to allow movement between Delta Quadrant and Alpha Quadrant (via a handy wormhole, wasn't it? ..or I might be mixing up my episodes... but there was a problem with time-displacement in the one I'm thinking of[4]) was a really trivial development!
But, you know, I can't remember
how they deal with the shoving of the originally-occupying air out of the way of the re-materialising person or object (or prevent an explosive in-rush of air into the gap left by the de-materialising one). "Arrangements Are Made", I imagine. A little bit of tractor-beam technology, perhaps, or simultaneously switching the matter in/out (and perhaps subtly integrating into/harvesting from the surrounding area, if not simultaneously switching destination atmosphere to the source location). Although we've seen "partial rematerialisation within bulkheads", on
very rare occasions in the set of series, when things went more doolally. When there's a risk of this happening (usually sub-space interference, but other technobabble may be mentioned) special beacons are often used, placed around the target of the person(s) they're trying to transport. I believe part of the magic of these devices is that they're constructed to be "reference" targets. When you can interrogate the stream and find out how these outlying items have been translated through the transporter-interfering phenomenon, you can use this information to fine-tune the handling of the rest of the stream of everything else that's being sent, to compensate accordingly.
Which is not to say that it's "easily explained", but a lot of the handwavium has been spelt out (or at least attempted to have been), for this series. Even if it's only in a form that's really an extra-thin shell or veneer of handwavium on top, so as to give it a plausible shape and texture. Still, if you prod it, it may still dent somewhat.
[1] We're talking a couple of decades of subsequent canon, though, I think. And I may have some details wrong. For the authoritative' information on this I suggest you find the Star Trek wiki, which is doubtless fully populated by all the available canonical information, by fans that are far more Trekier
or Trekkerier than myself. All the above is just memory, and thus doubtless incorrect in a number of ways. Not the least through any subsequent retconning that happened whilst I wasn't looking.
[2] Normally. Sometimes an originally sitting 'transportee' can arrive standing, in TOS especially, but that
shouldn't happen. And of course there are plenty of "transporter malfunctions" of varying (usually plot-related) degrees.
[3] Although there's debate, especially among the Barclays of the Trekkiverse, whether you've been killed at one end and only a copy (with false memories) is being reconstructed at the other end. Technically it's supposed to be the same material (and energy), I think, but it's still a valid philosophical solution. No wonder there's Transporter Psychosis.
[4] Just realised I
am mixing up my episodes. There's a Voyager episode where they get communications (through a wormhole) with a ?Romulan? science vessel, from pre-treaty times, but the transporting episode definitely involved Barclay having (despite his own fears) the engineering capabilities to create the more physical link.