The working of the electric motor is associated with Fleming's left-hand rule.
It states that if a current-carrying conductor is placed inside a magnetic field, it experiences a force in the direction perpendicular to the direction of the electric current and magnetic field.
These three physical quantities are placed in a mutually perpendicular direction.
So, in order to reverse the direction of force, you have to either change the direction of the current or magnetic field.