They tune the photon frequency and watch how the atoms respond. The probability that the atoms will be excited out of their ground state reaches a peak when the photons are tuned to exactly the right frequency. If the atom is oscillating at around 10 billion cycles per second then we've divided up the second by finer and finer steps. We get higher precision.