How do fossil fuels provide energy?

By a chemical reaction with oxygen (burning) they produce heat, which is energy