Reaction (or lack thereof) between oxygen and halogen gas
Your on the right track: in order to form a new compound, old bonds must be broken. This requires energy, even though the reaction may, overall , be exothermic. This is called the activation energy.
Think of it as pushing a car a short distance up one side of a hill before it reaches the peak and then rolls a long distance down the other side.
For example, in the dark, at room temperature, $\ce{Cl2}$ and $\ce{H2}$ coexist quietly in a flask... until light activates the chlorine (wait for the bang).
On the other hand, add enough energy, and even endothermic reactions take place, and, if the product is comparatively stable, or metastable, some can be left afterwards. For example $\ce{O2}$ is fairly stable, but given some energy input, e.g. from an electric discharge or from shortwave ultraviolet radiation, $\ce{O3}$, ozone, is produced, though that reaction is not thermodynamically favorable. The ozone is waiting to decompose... once it's activation energy is achieved.