Since you specifically mention pilot whales, I imagine you are interested in what causes mass strandings.
Pilot whales are one of the species that seem to be more inclined to mass strand.
Cetaceans that mass strand very often are offshore animals that have a highly evolved social structure. This means that for a pilot whale to survive in the wild, they need to be part of a fairly large group of whales. Sometimes what happens is that once a critical number of the school heads for shore, the rest of the herd is likely to follow. Many times when a mass stranding occurs, and people attempt to get the animals back to sea, they strand again. We're not really sure why that happens, but maybe they are confused from having been in shallow water or weakened by illness or starvation and find it difficult to come to the water's surface to breathe, and find it easier to be in shallow water.