"[Dimorphos] ... seems to be a loose pile of rubble barely held together by gravity — whose surface would probably shatter spectacularly when DART hit it.
DART [impacted] Dimorphos at more than 6 kilometres per second. The impact caused the asteroid’s orbit around another [larger] space rock [Didymos] to shrink — Dimorphos now completes an orbit 33 minutes faster than before the impact.
The impact ejected at least one million kilograms of rock from Dimorphos’s 4.3-billion-kilogram mass. The debris formed a tail that stretched for tens of thousands of kilometres behind the asteroid. Various telescopes watched over weeks as the tail shifted and evolved under the pressure of the Sun’s rays; the Hubble Space Telescope even detected a second tail, which had disappeared by 18 days after the impact.
One factor [in successfully changing Dimorphos's orbit] is that the spacecraft hit a spot around 25 metres from the asteroid’s centre, maximizing the force of its impact. Another is that large amounts of the asteroid’s rubble flew outwards from the impact. The recoil from this force pushed the asteroid further off its previous trajectory. Researchers estimate that this spray of rubble meant Dimorphos’ added momentum was almost four times that imparted by DART4."
It's good that this technique worked on a "loose pile of rubble", but I'm not sure we can assume all asteroids are composed in the same way. A denser rock of iron or similar might be more difficult to divert.