An earthquake is the result of a sudden release of “strain” that is built-up between two tectonic boundaries or at a fault line*, usually slipping in opposite directions.
The following video by the California Academy of Sciences shows a computer simulation of an earthquake at the Hayward fault which is one and the most concerning of several faults in California. The most famous fault being the San Andreas fault.