During the erosion of the surface the rivers cut valleys into the rocks. Orogenesis forms mountain ridges, powered by plate tectonic forces. All those processes are responsible, that the face of our Earth is never flat.
But any steep slope is vulnerable to the force of gravitation. And so, from time to time, mountains or escarpments collapse. Those collapses produce a pile of rocks, the debris of the collapse. The rocks have irregular shape, sharpe edges and moved to their new position by falling down or rolling down.
It is rather common to find cracks between those rocks. They do not fit, they just banged together, leaving some space between them. If the boulders are big enough, the spaces may be big enough for cavers.