Ground that felt perfectly firm underfoot can, in a matter of seconds of shaking, lose almost all of its ability to hold anything up.
Liquefaction happens in loose, saturated, cohesionless soils — typically sands and silts sitting below the water table — during strong ground shaking. The cyclic shear stresses from an earthquake want to shove those loose grains into a tighter, more compact arrangement. But the soil is saturated and the shaking is fast: the pore water trapped between the grains simply can't drain away quickly enough to let that happen. Instead, the water pressure between the grains starts to climb.