Electric motors use a kind of current known as AC or alternating current. Just like the name suggests, the current alternates, or goes back and forth. When magnets are involved, this causes the poles of the magnet to switch so that everything keeps spinning – it’s pulled south, then north, then south, then north.
Look at the picture below that represents a small, battery powered motor. This type of motor includes a piece called a commutator. Much like to commute means to drive back and forth, a commutator changes back and forth as well. A commutator is usually divided into two separate halves (the black semicircles in the diagram). Each half of the commutator attaches to an end of the coil. The commutator reverses the electric current each time half a rotation is achieved. As such, it keeps the coil spinning, one half turn at a time.
The motor’s battery sends electric current and is fed by terminals. The current is sent to the commutator through a pair of connectors called brushes because they brush against the commutator. They are made from pieces of soft carbon called graphite, or thin pieces of springy metal. The arrows in the diagram represent the flow of the electric current. The N and S represent the north and south poles of magnets and the lines between them are the magnetic field. As long as the commutator keeps alternating the current, the coil will continue to spin.
(Gif by Abnormaal – Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=4087521)