Locks keyed to work with a master key have three pins instead of two in the lock shafts. These master wafers allow two different keys to create a shear line along the spaces between the pins. With the pin lengths adjusted properly, one key can fit multiple locks.
Pin tumbler locks generally have two complementary pins in each of the shafts, with springs that push down on the top pins. When the right key is placed in the lock, each notch in the key pushes up on the bottom pin in each shaft to create a shear line between the top and bottom pins. This allows the inner cylinder to rotate freely within the outer cylinder, opening the lock.
Adding a third pin, or master wafer, to a shaft creates two spaces between pins. This allows keys with two different notch depths under a shaft to fit in such a way that the pins don't block the inner cylinder from rotating. By varying the master wafers in different shafts appropriately, a single master key can be designed to work in multiple locks, each with its own change key that works only in it.