P waves, then S waves
USGS compares P and S waves to lightning and thunder. Light arrives before sound, and the wait is longer when the storm is farther away. P waves are faster than S waves, so they arrive first. On a seismogram, the gap between them is short at a nearby station and longer at a distant one. That gap gives a distance. It does not give a direction. One station only knows that the earthquake was somewhere on a circle.
Why the textbook uses three stations
The USGS science page calls the next step triangulation. Draw the distance circle around three stations. The earthquake is at the place where the three circles meet. The page says it takes three seismographs for that reason. The epicenter people see on a map is that surface point. Depth is a separate unknown.
What the FAQ says the computer does
The USGS location FAQ describes the procedure that gets programmed. Guess a location, a depth, and an origin time. Compare the predicted arrival times with the times observed at each station. Nudge the guess in the direction that shrinks the difference. Repeat until the adjustments are small and the times fit. That needs a model of how fast waves travel through the crust under the network. The live map on this site plots locations USGS has already published. It does not run this calculation, and a plotted point is not a forecast of another earthquake at the same spot.