The core of The Earth is made from flowing molten iron, teamed with movement - produces a magnetic field around The Earth.
From what I can find, the South Pole is 'positive' and the North Pole is 'negative'
As each 'planet' has some version of this (including the sun) - (who switches poles...