Many in-ear and on-ear headphones isolate you from ambient noise. Some are better than others. The idea here is a physical barrier between your ear and the offending sounds. With over-ear headphones, the noise isolation usually isn’t a lot, but enough to muffle the surrounding sound somewhat.