Magnets are formed when an object produces it's own magnetic field and can attract or repel different materials. Something generates its own magnetic fields when the spinning electrons surrounding each atom line up just right. This can happen by exposing it to either a natural magnetic field, or an electrically induced magnetic field. Some very ferromagnetic (easily magnetized) material naturally become magnetized if the sit in one direction within earths magnetic field for a long time undisturbed. Sometimes objects can also be magnetized when exposed to a sharp blow. A moving magnetic field can also help magnetize an object. Such as when a magnet is rubbed against a ferromagnetic material. Electromagnets can be made simply by running current through a coil of wire. according to which way the coil is wound and also in which direction the current flows....will determine which side is north and which side is south. An AC (alternating current) source will be constantly changing from one pole to the other.