Why is it that energy is released from electrons when they move from one atom to a more electronegative one?
The previous answer is correct. I just wanted to add that atoms, electrons and generally matter, tries to ''organise'' itself in order to adopt a state, where it would have the lowest energy possible. An electronegative atom tends to attract electrons and has the ability of handling their charge better. Thus when an electron moves from a less electronegative atom to a more electronegative one, it is like moving from a state of high energy to a state of low energy. This is also described as realease of energy.
Due to difference in electronegativities the atoms have different binding energies and this difference is radiated in some form. If you're talking about a transition in a single atom the difference is the binding energies of different orbital/orbits/sheels.