I'll start with electromagnets. Amperes Law basically states that electric charges flowing (in a wire or space or wherever) create a magnetic field around their line of travel. Make a wire into a straight line and connect a voltage source and the magnetic field will be oriented in a circular fashion around the wire. If you coil the wire up, you add all of the fields together. On one side of the coil the field lines will be "leaving" and on the other side they will be "returning", since all magnetic field lines are circular. That gives a north and south pole. If you want to go deeper than taking Amperes law at face value, you'll need relativistic electromagnetics which would show you that if you traveled alongside the electrons in the wire, you would not see a magnetic field (no more moving charges) but instead an electric one. The results of any experiments would of course agree with one another but one would ascribe the effects to a magnetic field interaction and the other would see the electric field as the cause.
As for permanent magnets, the classical analog of looking at electron orbits as small current loops is a good place to start. As a classical idea its not actually correct, but can give you a first approximation as to how it works. Unbalanced outer electrons result in a net "current" and act like a loop of wire. In reality the quantum description is harder to grasp (and fills in the gaps and inconsistencies in this classical approach). In QM, the electrons have a magnetic moment due to their spin, as well as nuclear effects. But classical physics is easier to grasp and can be a good starting point.
Realize too that your idea of missing electrons prohibiting repulsions and causing "pull" from a positive nucleus is incorrect on at least two counts. For one, the atoms are (I assume) neutral, and their difference in number of electrons with the atoms of another metal is offset by more protons in the nucleus. But more importantly you're describing an electric attraction, not magnetic. Magnetic fields can align the magnetic dipoles in metals, which are usually oriented randomly. Once the metal's atomic dipoles are aligned by a magnetic field, the system wants to be in the lowest possible energy state, where their fields are closely coupled, so they "stick" together.
This is only a brief description of the concepts and I urge you to look at Wikipedia or other credible websites for the full story.