Notches cut into each wheel will also be aligned. These notches form a gap that will allow the lock to release and open.
Pin-and-tumbler locks are different, because they require a key to unlock them. Basic pin-and-tumbler locks have several spring-loaded pins inside a series of small cylinders.
When the right key slides into a pin-and-tumbler lock, the pointed teeth and notches on the blade of the key allow the spring-loaded pins to move up and down until they line up with a track called the shear line. When the pins align with the shear line, the cylinder can turn and the lock will open.