Before the electric traction motor was invented, steam locomotives were the primary way to power trains. early boilers were small and were vertically mounted. By 1830, it was learned that horizontally mounted boilers were better. Bigger boilers could be carried, with a lower center of gravity. A typical steam locomotive, after 1830, had a firebox at one end, usually covered by a cab. There a fire man could add fuel to the firebox. Early on, this was wood, but by 1900 it was almost always coal or coke. After 1900, some railroads would burn oil. No matter what fuel was burned, the hot gases in the firebox were sent through fire tubes to the smoke box at the front of the locomotive, where the gases were expelled up the smoke stack. The fire tubes passed through the boiler, which was a large tank of water. The heat would cause the water to boil and the resulting steam would collect in the steam dome. The steam would pass through the dry pipe to a place near the front of the locomotive, where it would be split into the two (or more) cylinders. The cylinders would have a piston that moved back and forth and was attached to a main rod. The main rod was connected to a driving wheel and connecting rods would link the main driver to other driving wheels.
Steam locomotives theoretically had no speed limit, but the vibrations caused by high speed operation and the limits caused by the abilty of the boiler to produce steam placed limits on a steam locomotive's top speed. The quality of the track also placed limits on top speeds too. After 1900, there were many steam locomotives that were capable of going 120 miles per hour, but safety concerns placed speed limits of 79 miles per hour on most of the first class trackage in the United States. The fastest steam locomotive was the British A4, which was clocked at 126 miles per hour, over a measured mile. That is the "official" record, but the Pennsylvania Railroad once measured a much smaller E-2 class locomotive at 127.2 miles per hour, back in 1905. This was under less stringently controlled conditions and is not the official record.
Steam locomotives are moderately difficult to produce. During the 1800s, when they were still rather small, a lot of railroads in the United States could build their own steam locomotives. After 1900, when they grew much larger, specialized locomotive builders dominated the market. In the United States, these were American Locomotive, Baldwin and Lima. These companies had factories that could mass produce large locomotives at a cost that was lower than what most railroads could do in their own shops. In the early twentieth century, the Milwaukee Road, Southern Pacific and Louisville & Nashville stopped building their own locomotives because labor costs were rising too fast and the locomotives were out growing the size of their shops. During the Great Depression, it is said some railroads, like the Great Northern, Cotton Belt, Burlington and Missouri Pacific built some new locomotives, but assembled is a better term. These railroads would buy a boiler from Alco, Baldwin or Lima, which comprised about 70 % of the weight of a new locomotive and fit it on a bed frame they got from General Steel Casting. They would then buy the appliances they needed, like driving wheels from Box-Pox or feed water heaters from Worthington, and assemble these parts in their back shop. This put some laid off employees back to work, even if they only fabricated about five percent of the parts used on the new locomotives.
Source: The Historical Guide to North American Steam Locomotives. by George Druery.
http://www.steamlocomotive.com
I'm not sure I understand your question-- locomotives aren't electric. Modern ones are powered by diesel engines, early ones were powered by steam generated by coal fired boilers.
If I'm misunderstanding the question, please clarify.