A mechanical device which converts energy into a force that can do work.
A motor is a mechanical device which converts energy into a force that can do work.
In this case the motor is electrically powered. By applying a source of electrical energy to the motor, it will begin to spin the output shafts, converting the electricity into torque.
NMRA standards call for the Red wire to connect to the right rail and the + (plus) terminal of the motor. The Black wire connects to the - or minus terminal. The Red wire may also be connected to a center rail pickup, an outside rail, or catenary via a trolley pole or pantograph for traction models. The power source is typically Direct Current
When a decoder is installed between the power source and the motor, the Red and Black wires are replaced with Orange and Grey, respectively.
There are a number of motors used in model railroading. The most common is the can motor, named for its shape. Another motor type is the coreless motor. Models with coreless motors should never be placed on a DCC layout, as the DCC signal can destroy the motor, quickly.
Other motors are open frame, often found in old models, brass locomotives, and some commercial production models. Just as there are different motors, there are different drivetrain arrangements too. Some models may use a pancake motor mounted on the truck assembly directly driving the gear train, instead of a can motor mounted mid-ships and driving the wheels using a worm gear to transfer the torque to the gears driving the wheels.
NMRA Wiring Standard: RP 9.1.1