Actually, protons and electrons do not physically spin. But because they act as if they do, physicists have borrowed the term to describe their behavior, which otherwise is quite mysterious. Similarly, electrons do not actually orbit atoms. They exist in a cloud around the nucleus. But again, they behave as if they were circling the atom.
All atoms are miniature magnets, a result of the motion of their component parts.
In most materials, atoms are oriented in different ways, so that the fields cancel each other. A few materials, such as those made of iron, cobalt and nickel, can become large-scale magnets because their atoms readily arrange themselves and their electrons so they all point the same way. As sediments containing iron-rich mineral particles are slowly deposited in layers at the bottoms of lakes and rivers, their atoms are gently tugged into alignment with the Earth's much larger field. Since opposites attract, this is why the north poles of compass needles point that way. It is made possible because the magnetic properties of each element's nucleus are different.