The photodetector is built around a square light-sensing chip which is divided into four quadrants. The circuit monitors the electrical power the light creates in each quadrant.
By comparing the four signals, the circuit (and subsequent electronics) can figure out where the beam is: If it is centered on the detector, equal amounts of light strike the corners of the four quadrants (producing the same power); If the beam strays from the center, one or two quadrants receive more light and generate more power.