It's like the voltage regulator on your car. The car's alternator is pumping out power and the regulator is topping up the car's 12v system (actually 13.9). The regulator doesn't want to create an over-voltage situation and so dumps any extra power to a resistor, turning it into heat. On an electric train, instead of a battery the regulator is pushing power back to the third rail. Once the rails max voltage is reached, when it is at capacity, everything else is turned into heat via resistors on the train.