A three-way bulb has two filaments in it. The next time one burns out, carefully open it (for example, wrap it in a towel and hit it lightly with a hammer) and you will see the two separate filaments.
For the lowest setting, one filament comes on (it might be a 50-watt filament). For the next setting, the second filament comes on (it might be a 100-watt filament). For the third setting, both come on, for (in our example) a total of 150 watts.
Look also at the end of the bulb's base -- you will be able to see how the lamp controls the two filaments.