How does an inductor store magnetic energy?

How does an inductor store [electro]magnetic energy?

Rather surprisingly, it's something like a flywheel. You can see a mention of that here in Daniel Reynolds' electronics course:

enter image description here.

It really is like this, check out the pictures of inductors on Wikipedia, and you'll notice they're rather like a solenoid. And there's the flywheel again: "As a result, inductors always oppose a change in current, in the same way that a flywheel oppose a change in rotational velocity". Why is an inductor like a solenoid? Because a solenoid is like a bar magnet, and a bar magnet is a magnet because all the electron spins are aligned.

Don't think of those spins as something abstract, there's some real angular momentum in there, as evidenced by the Einstein-de Haas effect. This "demonstrates that spin angular momentum is indeed of the same nature as the angular momentum of rotating bodies as conceived in classical mechanics". The point to appreciate is that electrons move in a rotational fashion, so what you've got is in essence a whole load of subatomic flywheels. And as you know, flywheels aren't always easy to stop. Hence people have been killed when they've opened the switch on a "highly inductive circuit", see this question. And in turn, that happens because of the "screw" nature of electromagnetism, wherein Maxwell said "a motion of translation along an axis cannot produce a rotation about that axis unless it meets with some special mechanism, like that of a screw". The current is the motion of translation, the flywheel is the rotation, and you can't stop it by just opening the switch. That flywheel is going to keep on going, and so is the current.

The energy is stored in the magnetic field. I usually think of it as "magnetic field lines repel" but that is not very precise (useful for intuition though).

But along the same lines as your capacitor example (moving the plates to infinity takes work), if you look at a simple current loop there is a force on the wires from the magnetic field generated. This force is repulsive: the loop would like to get bigger. If you could slowly "grow" the loop, you could do work in this way. And the amount of work done is once again equal to the energy stored. Just like for capacitors.

I deliberately stayed away from equations - hoping this verbal picture helps your understanding.