Why are mushrooms growing on top of your grandmother's grave?

Because graveyard soil tends to be rich in organic matter, there is a chance that mushrooms may grow around the graves.

Specifically, the soil-dwelling critters of the soil food web die and decay. Their body parts break down and in so doing enrich the soil with nutrients such as nitrogen. The nutrients tend to stay in place in graveyard soils. So the nutrients are there to be accessed by plants - such as mushrooms - that favor nutrient-rich soils.