They occur where a band of hard rock (e.g. granite) overlies a softer rock (e.g. sandstone).
Erosion processes such as Hydraulic Action (the force of the water) and Abrasion (where the river rubs stones that are being transported against the bed of a river thereby breaking it down) dominate.
The softer rock is eroded quicker than the harder rock and gradually washes away downstream.
This creates a plunge pool where water is swilled around, potholing can occur here and any rocks and debris swept into the plunge pool by the river will be swirled around and rub against the bed and banks of the plunge pool (called corrasion), deepening it further.
Over time, the softer rock is eroded further creating an over hang of hard rock. This overhang is unstable as it's weight is unsupported.
Eventually, this hard rock collapses because it is unsupported and the waterfall moves back upstream.
This creates Gorges, which are steep sided deep river valleys. This process will repeat continually, with the location of the waterfall moving back upstream.