A diverter tub spout works by blocking off the flow of water to the tub spout. This forces the water to the shower head instead.
Incoming water flows through one pipe that connects to both the tub spout and the shower head. Because the water drains into the tub first, there's not enough pressure to run the shower at the same time. Regardless of the specific design, all diverters work the same: when the user activates the shower, the diverter closes off the tub spout. This prevents water from flowing through the spout, forcing it up and out of the shower head instead. Without a shower diverter, two separate pipes would be necessary to supply water to both areas.