Sound waves occur when an object vibrates and transfers that energy into the air or another medium. When a vibrating object moves forward, it compresses the air molecules in front of it, and when it moves backward, it leaves a gap where they can expand or rarefy. The vibration produces many of these compression and rarefaction pairs, which travel away from the source of the vibration through the air.
When sound waves arrive to a listener, the process occurs in reverse. The compressed air waves push against the listener's eardrum, while the rarefied air behind those waves allows it to vibrate outwards. The movement of the eardrum is transmitted to the brain, which interprets the vibrations as sound.
Sound travels much faster through water because it is a denser medium than air. Since a pressure wave only propagates when the molecules in the wave strike other molecules, the more molecules there are, the faster the wave travels. Since a given volume of water has many more molecules in it than the same volume of air, sound travels around four times faster. It also travels much farther in water than it can in air.
Sound waves travel the fastest through dense, solid objects. In this case, sound forms a transverse wave instead of a compression wave, since the energy required to compress solid material is much greater than a liquid or gas. Depending on their density, solids can transmit sound more than 10 times faster than air.