What happens in terms of energy and stability when a covalent bond forms?

I remember my teacher telling me that covalent bonds are stable

You might want to describe what happens by referring to an energy level diagram

http://www.gcsescience.com/rc24-energy-level-diagram.htm

the wander walls force of attraction increases,it become more stable and it requires less energy.

When a covalent bond forms, there is a sharing of electrons between two atoms. This sharing occurs when each atom contributes one or more electrons to a common electron cloud, resulting in the formation of a molecule.

In terms of energy, the formation of a covalent bond involves an energy change. The energy change can be either exothermic or endothermic.

During the formation of a covalent bond, when atoms come close together, their electron clouds start to overlap. This overlapping leads to the formation of a more stable, lower energy state compared to the individual atoms. When the atoms become more stable, energy is released, resulting in an exothermic reaction.

On the other hand, if the formation of a covalent bond requires energy input, it is an endothermic reaction. In this case, the energy needed to overcome the repulsion between electron clouds is greater than the energy released by the formation of the bond.

The stability of covalent bonds is based on the principle of the octet rule, which states that atoms tend to gain, lose, or share electrons to achieve a stable electron configuration with a full outer shell of electrons (typically eight electrons). When atoms are able to achieve a more stable electron configuration by sharing electrons, covalent bonds are formed, thereby increasing stability.

To determine the energy change associated with the formation of a covalent bond, one can calculate the difference in potential energy between the separated atoms and the bonded molecule using quantum mechanical principles and computational chemistry methods. Experimentally, the energy changes can be measured using techniques such as calorimetry or spectroscopy.