Normally, power comes from the utility and the power comes into the panel through the main breaker. The main breaker energizes the two bus bars in the panel. All of the branch circuit breakers are connected to the bus bars (120V breakers are connected to only one of the bus bars, 240V breakers are connected to both). Since the bus bars are energized, and the all of the branch breakers are connected to the bus bars, all of the branch breakers have power.
When the power goes out and you switch to generator power, you shut off the main breaker and turn on the generator breaker. The generator breaker is a 240V breaker, therefore it is connected to both bus bars. The power now comes from the generator, through the generator breaker, and energizes both bus bars. Once again, since both bus bars are now energized, and all of the other branch breakers are connected to the bus bars, all of the branch breakers are energized and can be powered from the generator.
Basically, the goal is to get the bus bars energized, whether it's from the utility or a generator. Energized bus bars = all branch breakers energized.
I think what the OP is failing to realize is that power can flow through a breaker both ways. Normally, the bus bars are energized via the main breaker, THEN the power goes through the branch breaker(s), THEN the power goes through the wire(s) connected to the branch breaker. But breakers also work when power flows "backwards." You install a generator breaker (which is simply a normal 240V branch breaker) and connect wires to it. The wires connect to the generator inlet on the side of your house. Now when you use a generator, power comes from the generator and into the generator inlet. THEN it goes through the wiring to the breaker panel, THEN it goes through the generator/branch breaker, THEN it energizes the bus bars.