Often when trying to understand sound waves, it’s useful to visualize a spring or a slinky (remember those?)
If you push a spring from one side, a pulse is created.
This pulse travels through the spring causing the hoops of the spring to move closer together.
Each hoop pushes on its neighboring hoop, moving it forward. The collision of hoop #1 with its neighbor restores hoop #1 to its original position and displaces hoop #2 in a forward direction, and so on.
This back and forth motion of the slinky hoops in the direction of the energy pulse creates regions in the spring where the hoops are either pressed together (compression) or spread apart (rarefaction)
This displacement pattern moving through the spring is similar to how sound pressure travels through the air.
Suppose that same slinky is now stretched out horizontally and a pulse is introduced by vibrating the first coil up and down.
A pulse of energy will be carried through the slinky from left to right and the coils will move up and down.
The displacement pattern moves the particles of the medium perpendicular to the direction of the pulse.
Waves traveling through a solid medium can be either transverse waves or longitudinal.
Waves traveling through fluid or gas (air) are always longitudinal.
Transverse waves require a rigid medium to transfer their energy.