Because they become more stable. It requires less energy to be a molecule or compound than it does to be an individual atom, and they give away excess energy when joining for the sake of stability and since it is no longer needed, generally given off in the form of heat. They gain this energy back when the bond is broken, since it takes energy to release a bond, i.e. the spark in your cylinder that ignites the gas.
Source + good reading material on the matter:
https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Chemical_Bonding/Fundamentals_of_Chemical_Bonding/Bond_Energies
Latest Answers