Sperm whales that are beached are very large and dense creatures, so it is almost impossible for them to get back out to sea on their own and they usually die through dehydration and crushing themselves. The dead carcasses of spem whales will decompose (very quickly if it is warm and there is a lot of sun) and as these gases build up inside such a large body, eventually the creature will bloat up. Just like a balloon that was inflated past its breaking point, at a certain point the whale's skin will violently and noisily tear up as the gases seek to escape, which causes them to explode after a fashion.