Sound wave has different speeds in different mediums because:
more elastic 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 of the medium increases. Also, the speed increases with increased elasticity of the medium. The reason sound propagates faster through metals even though they are denser than gases is that they are elastic. 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.