Sound travels in waves. They have a positive side and a negative side. The waves can have different shapes. They can move slow and you hear a low hum, or faster and you hear a high pitch.
Noise cancelling headphone use one or more microphones on the outside to receive the noise - along with a microphone on the inside of the headset. The outside mics are used to duplicate the noise and a simple circuit inverts it...… big positive waves are made into big negative waves, etc etc. The inside mics tell the circuit how loud/how much of the inverted signal should be inject to properly cancel the noise.
Passive models simply use a basic circuit to grab the noise, invert it, and inject it. They are about never 100% noise canceling.
Active models need a battery and really, really good insulation because after the circuit dicks with the sound it is a tiny bit delayed. Hearing even a small amount of the real noise mixed with the delayed signal is very annoying.
Acoustic models run the sound down a gauntlet of tuned cavities. Bouncing off of obtuse angles allows the sound to change phase and can cancel out noise. These are especially good for constant noise - like working around a very noisy electric motor or engine.
There is more to this. Allot more. Its also all online. There are audio engineers that do nothing but comb rooms and buildings to PA and music actually sounds nice. I helped design an audio system for an international airport - we brought in such a technician. He worked with the building designers to change the size of rooms and location of walls so normal conversation would not carry, and, chose the precise locations for speakers that made the music and PA system sound just awesome. People who do this kind of work - are the ones who design the noise cancelling headphones.