Earthquakes are caused by sudden movement in opposing tectonic plates in the earth. As plates move against each other, sometimes the rocky edges catch against one another. The rest of the plate remains in motion, putting stress on the sticking point, and when it gives way, an earthquake occurs.
When two tectonic plates are passing one another, the amount of kinetic energy involved can be enormous due to the large mass involved. When the edges catch, the friction builds up energy like a stretched rubber band. Eventually, the motion of the plates overcomes the resistance of the stuck area, and that energy is released suddenly in the form of vibrations. These waves travel through the surface of the earth, causing an earthquake.
In many cases, an earthquake can be preceded or followed by additional shocks. These are smaller quakes caused by smaller slips between the two plates. A cluster of small tremors can indicate a fault that is building up large amounts of stored energy, and can warn of a major earthquake.
One potential side effect of an earthquake is liquefaction. When soil that contains large amounts of water is suddenly shaken by a tremor, it can begin to behave more like a liquid than a solid. This can cause a sudden subsidence in the surface, creating sinkholes and causing structures to tilt and sink wildly.