Imagine a slinky: when you push one end, the compression travels down the slinky, causing the coils to bunch up and then spread out again. The coils themselves don't move far, just a little bit back and forth.
Similarly, when a P wave passes through rock, it causes the particles to compress and expand in the direction of the wave's travel. This back-and-forth motion is what transmits the energy of the earthquake.