A magnet exerts a force on any piece of magnetic material including iron and steel, or another magnet which is placed near it. (There is a magnetic field around the magnet).
A coil of wire acts like a bar magnet when an electric current flows through it.
One end becomes a north-seeking pole and the other end a south-seeking pole.
This is called an electromagnet.
Reversing the current in an electromagnet reverses the poles of the electromagnet.