Here's why:
* Mechanical waves require a medium: Sound waves, for example, need air, water, or a solid to travel through. They are vibrations that transfer energy by causing particles in the medium to move.
* Electromagnetic waves are self-propagating: They are made up of oscillating electric and magnetic fields that generate each other. These fields can exist even in the absence of matter, like in the vast emptiness of space.
This is why we can receive sunlight, which is an electromagnetic wave, on Earth even though it travels through the vacuum of space.