Stim generates multiple (say N many) noisy samples by first collecting one reference sample, then running a Pauli frame simulator N times to track which errors may flip which measurements and eventually combining the N flip patterns with the same reference sample N times to produce N noisy samples. The reference sample is collected by simulating the circuit with no errors.
For example, on thousand qubit circuits with millions of measurements, Stim can take a few seconds to produce its reference sample. But then it starts spitting out thousands of circuit samples per second. What it's doing is pretending noiseless runs always produce the reference sample, except it's perturbed by the noise in the circuit. A key thing here is that the distinction between different choices of reference sample is removed by adding a 50/50 Z error after every reset and measurement. The set of noiseless samples forms a group and you sample uniformly from that group via these 50/50 Z errors.
Why can Stim pretend that noiseless runs always produce the reference sample and so add a 50/50 Z error after every reset and measurement to make up for the randomness of outcomes when sampling the noiseless circuit N many times? After a measurement for example, it may be that adding this occasional 50/50 Z error accounts for the probability of having either of two eigenstates as the post-measurement states. What if, the probabilities were not 50/50 though?