HOW DOES IT ACTUALLY WORK?
When ever a current carrying conductor is wounded around a cock and is placed between the magnets,electric field(due to flow of electrons in the conductor) and magnetic field(due to the magnets) interact with each other resulting in the motion of the cock.The direction can be known by Fleming left hand rule and can be changed by changing the direction of current(flow of electrons) . This is how the electrical energy is converted into mechanical energy.