How do seismic waves affect rock as they travel through it?
There are several kinds of seismic waves, but we’ll stick to two.
Primary waves (p-waves) are longitudinal or compression waves, so the rock is oscillating parallel to the direction of travel of the wave. They tend to arrive first, hence their name, as they move slightly faster through the crust. As they come from below, they make buildings/objects jump vertically and cause relatively little damage.
Some time afterwards (typically several seconds, but it varies) the secondary waves (s-waves) arrive. These are transverse waves (their displacement is perpendicular to the direction of motion of the wave) so cause the ground to shake back and forth. These cause the vast majority of the damage (buildings are much weaker in this mode of oscillation) and as a result of building collapse, the vast majority of the deaths and injuries.
Hope that helps.