it might be helpful to remember that forming a bond doesn't release energy per se : there's a lot of substances around with a positive Δ Hf (with respect to the elements they're composed of)
hence, some bonds also might store energy
as a result a system will always form bonds "at free will" only when there is a net loss of energy for the system thereafter (and if kinetics allow for the process in the first place) - and otherwise has to be forced to do so by an input of energy into the system (or else nothing will happen)
regards
Ingo