That happens when two atomic nuclei collide with each other, releasing energy in the form of photons.
This energy is librated at the center of the Sun as billions upon billions of nuclei of hydrogen atoms collide with each other and fuse together to form nuclei of helium, and in doing so, release some of the energy that is stored in the nuclei of atoms.