If a stretched rubber band is broken or cut, elastic energy stored in the rubber band during the stretching will suddenly be released. Similarly, the crust of the earth can gradually store elastic stress that is released suddenly during an earthquake.
Most earthquakes are the result of the sudden elastic rebound of previously stored energy.
The following diagram illustrates the process. Start at the bottom. A straight fence is built across the San Andreas fault. As the Pacific plate moves northwest, it gradually distorts the fence. This diagram greatly exaggerates the distortion.