If you are looking for how the energy is conserved, there is an attractive potential between the electron and proton that releases potential energy when you make a hydrogen atom. So you end up with energy in light, and negative energy in the potential energy of the atom. That potential energy has physical effects like reducing the inertia and the gravitational field produced by the particles, etc.