This is how active noise cancellation works in headphones. You stick little microphones on the outside of the headphones, then play back what’s picked up through the headphones themselves but with a very slight delay so all the peaks and troughs match up. The problem is that you need to put out sounds at least as loud, and that’s a pretty bad thing to get even slightly wrong if the energy levels are that high.
Not sure how all NC earpones work, but I'd say you still need the delay to properly process the sound and mix it with whatever is playing (unless you rawdog the input flipped and amplified directly in analog).
Normally sounds don't change in frequency that often so that's good enough (tm). I can hear myself typing now (short burst of sound), but the washing machine nearby, which is louder without earphones, is completely gone.