Mechanical waves transfer energy by inducing vibrations in the propagation medium. Electromagnetic waves do not require a medium for propagation, but still transfer energy by having an electric and magnetic field propagate perpendicular to one another.
The upwards and downwards motion of particles in transverse waves and the horizontal motion of particles in longitudinal waves transfer energy through the medium of propagation. Waves transfer energy without transferring mass. An ocean wave washing up against the shore does not carry individual water particles from deep in the ocean to the shore. The water molecules, salt, sand and other particles excited by the wave vibrate perpendicular to the direction of wave propagation, making these transverse waves. They are lifted up as the crest of the wave passes. If there are several consecutive waves, the crest is succeeded by a trough, which displaces the medium particles downwards. Changing perspective from the entire wave to a single particle shows this particle moving up and down periodically as the consecutive crests and troughs of waves pass by it.
Particles can also vibrate in the same direction of wave propagation without being transported, as with sound waves. Sound is a longitudinal wave consisting of consecutive compressions and rarefactions. Compressions cause the particles of the medium to come closely together, while rarefactions cause the particles to spread more widely apart than they are when a wave is not propagating.