When fossil fuels are burned carbon and hydrogen react with oxygen in air to carbon dioxide (CO2) and water (H2O). During this reaction heat is released which further amplifies the reaction. Electricity is generated by transforming mechanical energy (heat) to electrical energy in a turbine or generator.
One may know how close the molecules within the substances are packed together. Hot substances have molecules that are farther apart, cold substances have molecules that are more compact/closer together.