Why cakes sink after baking and how to fix it

Why cakes sink after baking and how to fix it

The cake rises well during baking but sinks in the center after cooling, even when the recipe is followed exactly.

What usually causes this, and how can it be avoided in home ovens?