I heard that exercise gives you more energy. How is that possible?

Adrenaline. When one exercises, the increased activity causes a rise in your adrenaline level. Adrenaline is your body's natural stimulant, the effects of which cause you to feel more stimulated, energetic, and/or more alert.
Muscle Efficiency. Exercising does several things, but first and foremost it produces a natural high that improves one's mental health. Second it trains the muscles to be efficient: i.e. To work to the best of their capability to be strong and to metabolize the calories they get efficiently. Without regular exercise muscles do not work efficiently, they get bogged down with excess carbohydrate calories.