Mechanical clocks use pendulums or balance wheels - things that oscillate at very regular intervals. Quartz clocks use the vibration of a crystal when electrified. Atomic clocks use the vibration of atoms.
Atomic clocks are so accurate they lose less than a second over millions of years.