Earthquakes are usually caused when rock underground suddenly breaks along a fault. This sudden release of energy causes the seismic waves that make the ground shake. When two blocks of rock or two plates are rubbing against each other, they stick a little. They don't just slide smoothly the rocks catch on each other and still pushing against, but not moving.
The spot underground where the rock breaks is called the focus of the earthquake. The place right above the focus (on top of the ground) is called the epicenter of the earthquake.