Electromagnetic waves travel in straight lines but do all waves travel in straight lines?
Like electromagnetic waves, mechanical waves, and (in fact) everything travels in a straight line until something acts on it causing it to stop going straight or until the medium it's travelling in changes. Light will bend due to gravity, refraction, reflection. Without an outside influence and in the same medium, everything travels in a straight line.
Consider running in an open field, you'll go straight until something pushes or pulls on you, or until you decide to use your legs to forcibly change direction. The bending due to changing medium can be thought of the same way. Consider running in an open field. On your right, nothing. On your left, there's a crowd of people all of whom have their hands out, trying to block your path but not stop you (a denser medium). If you run straight into the crowd, you'll stay going straight. But if you run towards the crowd at an angle, part of you will hit their hands first and slow down. The other part will keep going as fast and you'll ten to turn towards the crowd. This is refraction. I went through and explained it all to show that everything, not just waves, acts the same. Everything tends to move in a straight line until it goes to a different medium or something acts on it to actively change its path.
Electromagnetic waves don't always travel in straight lines. They can bend when they encounter a changing wavespeed at non-normal incidence, this is how a lens works. Mechanical waves act in the same way. They travel in a straight line until they encounter a change in the material parameters (such as a change in density) which changes the speed of the wave.
For more information, have a look at this presentation about scattering and attenuation of seismic waves inside of the Earth.