Nib asked, and Nib — askNib's tutor — drew the answer live at a whiteboard. This is the spoken transcript; enable JavaScript to watch it drawn.
why do magnets repel each other
Magnets don't always repel. Opposite poles attract, and only matching poles push apart. So the real question is: why does a matching pair shove each other away?
The source is inside the metal. Every electron is a tiny magnet, and in a magnet many of them line up the same way, so their tiny pulls add up.
A magnet fills the space around it with a field, drawn as lines running out of north and into south. Unlike poles: the lines join up, end to end.
Now like poles. The lines can't connect, so each magnet's lines bulge outward and crowd together in the gap, squeezing against each other.
Field lines act like rubber bands: they pull along their length, and push sideways on their neighbours. Joined lines pull magnets together. Crowded lines push them apart.
So: matching poles repel because their fields squeeze together, and opposite poles attract because their fields link. All of it comes from aligned electron spins.
Magnets only push apart when matching poles meet, because their fields crowd together like pressed rubber bands in the gap.