Longitudinal waves move by compressing and rarefying the medium through which they travel. In these waves, the particles of the medium oscillate back and forth in the same direction as the wave propagates. This movement creates areas of compression, where particles are close together, followed by areas of rarefaction, where particles are further apart.
To visualize this, think about how a slinky works. If you push and pull one end of the slinky along its length, the coils move in and out, creating regions of tighter coils (compression) and more spaced-out coils (rarefaction). Similarly, in longitudinal waves, such as sound waves, the energy travels through the medium (like air, water, or solids) as these compressions and rarefactions move outward from the source of the wave.