When magnets attract each other, the two objects move on their own, even though they have mass, and this motion can* be calculated as the energy that would be spent to move two objects with similar mass but without any substantial macroscopic magnetic interaction. *Not saying this is how energy has to be calculated but instead saying that the calculation can be done, whether one says it is meaningful or not.
Another way to calculate an energy here, is to say we now use two electromagnets of the same mass as our magnets, make sure to obtain the same motion from them using an external power supply and, well, see how much electrical energy was used. I am speaking in terms of an experimental setup but of course there are existing formulas that will do well.
One way to imagine where an energy could come from to move the two "autonomous" magnets is to say the energy was waiting somewhere, stored after or even when the magnets were set apart, then was released, like a spring, to bring them back together.
Obviously this picture is less intellectually satisfying for magnets that were never stuck together before, and could lead to even more dubious suggestions like saying all magnets were initially stuck together when the universe was created and will spend their entire existence looking for their soul mate. However I do not exclude the possibility that today's magnets are a sort of perturbation of the initial conditions that would recover when such spontaneous movement occurs. I just do not know.
So as far as I know (e.g. Wikipedia), in the case of simple magnets, the magnetic attraction is due to electrons spin ordered in a certain way in the materials involved. In this description, there is no energy used in the sense of the energy expenditure described above, not even, to my knowledge, a transduction of some sort. But I am unaware of the adequate description of the system at work, thus my question.
So where is the energy in the system? Where is it before, during and after the magnets moved and joined together? Please answer in terms of energy, and not work or force, and in plain English as I am trying to understand the physical process involved at a molecular and electronic level, not at a thermodynamic or macroscopic one. If someone can provide an exact description instead of an approximation, that would be perfect.
As a side note, I am aware, or at least I remember reading that somewhere, that a composite object such as an atom with a nucleus and electrons has less energy than its constituents if they were spatially separated. There is an analogy here (and maybe more), the two magnets having less energy once they reach each other, requiring extra energy to set them apart. In the case of electrons joining the nucleus, there might be radiation released, which is energy, so the same question applies there too. As if some energy that favored the independence of the electron or magnet was lost after they were bound. But my question centers on magnets only.