Railfans use the builder's number to trace locomotives. Baldwin used class numbers to trace locomotives (for example, 8-18c-4 meaning 8 wheels, a reference to locomotive size (18) the mix of driving and trailing wheels (I don'r remember if "c" is 4 wheel lead truck or 4 driving wheels, and assumes all the rest are lead wheels), and finally a number (in this case 4) referenceing that in this case this is the 4th loco of the class. There is also a plan number listed in the specification sheets.
Randy Hees
Sometimes a railroad history will include the class number. If not, you have to look it up at one of several archives which hold the information. Most is at the DeGolyer Library library (Dallas Texas) but the California State Railroad Museum has microfilm of some the specification sheets with indexes. The Smithsonian Archive has the order books.
It can be a slog to find the information, but it is do-able if you are willing to look.