Sound waves have different speeds in different media because:
more incompressible the medium is, faster the speed
The speed of sound depends on the density and the elasticity of the medium. The speed of sound decreases when the density increases and speed of sound increases with the stiffness of the medium. This is generally true for all kind of media. The speed increases with increased stiffness of the medium. The reason sound propagates faster through metals even though they are denser than gases is that they are stiffer (i.e., less incompressible). For example, steel is 6000 times denser than air but 2,000,000 times more elastic than air, so sound travels 16 times faster in steel than in air.