Noise-canceling headphones work by creating a noise-canceling wave that is 180 degrees out of phase with the ambient noise around you.
This wave acts like a noise eraser and cancels out any surrounding sounds that diminish the audio you really want to hear. Noise-canceling headphones aren’t magic, but they can feel like something close to it in the right situations.