On a previous show we discussed how, every 250,000 years or so, the north and south poles switch places. Not that the places themselves move, rather, the entire magnetic field of the earth flips around, resulting in the pole we now call north being on the southern tip of the planet, and vice versa. Why does this happen?
Although it seems pretty solid, the outer core of our planet is in a molten state. That means it's partway between what most folks would call liquid and solid. Much of this molten interior is iron and nickel. These are elements that conduct electricity very well.
It's the fluid metals that move about inside earth that generate a magnetic field around our entire planet. Although from close up these metals are bubbling like hot soup, you could also say that in general their motions follow a pretty steady pattern. That's why the magnetic field on earth is pretty stable.
Every so often, however, that regular motion is interrupted. Think of what happens when you stir that bubbling soup. It takes a few minutes for things to settle down and the regular pattern of bubbling to resume.
That's probably what happens inside earth. Something, maybe nothing more than naturally occurring variations in the process, disrupts the otherwise regular flow of metals in our planet. This shuts off the magnetic field for a while. Eventually, things start bubbling away again and the magnetic field returns. When it comes back on, one end will be north and one end will be south. Whether or not they were aligned that way before the disturbance is a matter of chance.