An earthquake is caused by a sudden slip on a fault.When the stress on the edge overcomes the friction, there is an earthquake that releases energy in waves that travel through the earth's crust and cause the shaking that we feel. In California there are two plates - the Pacific Plate and the North American Plate.
It is caused by a certain and sudden slip in a fault, This realease of energy causes the sesimic waves to make the ground shake. (as known as tectonic plates)