Chemical bonds are fairly easy to understand in terms of electron clouds.
We know that electron clouds around atomic nuclei come in layers, in which the innermost layer can have a maximum of 2 clouds, the next one out a maximum of 8, and farther out still another 8, etc.
The way this works when modelled with bouncing electrons is that electrons sometimes find ways to bounce off more than one atomic nucleus at a time.
In the case of hydrogen molecules, we have two protons held together by two electron clouds.
Since every hydrogen atom has 2 available slots in its inner layer, yet only 1 electron cloud, the most efficient configuration of two hydrogen atoms is to have them share their respective electron clouds to make the most of the available space. The electrons bounce alternately off one and the other proton.
The 2 slots available for electrons to bounce are thus filled. Instead of each proton having only one electron bouncing off of them, both of them get two slots filled through mutual sharing of their single electrons.
This yields a more efficient configuration, and energy is released in the process.
Hydrogen molecules can in turn be combined with other atoms to make larger molecules. Two hydrogen molecules can combine with a carbon atom to create methane. This too releases energy.
Carbon has 4 empty slots in its second layer. When these slots get filled with electron clouds associated with the hydrogen molecules, a configuration can be made in which all 8 outer slots of the carbon atom are filled in such a way that every hydrogen atom has its 2 slots occupied.
Note that efficiency is related to size. Two independent hydrogen atoms occupy more space than a single hydrogen molecule. Two hydrogen molecules and a carbon atom occupy more space than a single methane molecule.
The process of going from big and bloated to small and compact releases energy. The more compact a configuration, the less energy is left in it for further reactions.