Railroad companies developed standard sets of rules that train crews and dispatchers were expected to follow. Collisions and derailments were widespread on the early railroads and the rules were designed to prevent accidents.
Operating rules covered every aspect of running and assembling trains: safe coupling/uncoupling procedures; testing of air brakes before departure; other required safety checks; communication rules to prevent confusion; the myriad signals governing train movement on mainlines, on branchlines, and in yards and the signals' precise meanings; rights-of-way on single tracks and also at junctions (called on a railroad, 'interlockings'); rules to prevent collisions on single and multiple tracks; procedures to ensure verification that crew members understand train orders that they are given during a run; what to do after derailments; what to do if a train has to make an unscheduled or unexpected stop when other trains are following; what to do in other emergency situations, etc. The objective was that all crews everywhere on the railroad have shared understandings of what to do in dangerous situations -- and railroads and rail yards were and are always dangerous.
A major point needs emphasis: A great deal of individual judgement by conductors and engineers was required in everyday operations. Examples: the early detecting by trainmen or the conductor of small signs indicating potentially hazardous defects in a car's brakes or wheels, or the safe operation of a train in conditions of limited or marginal visibility, or the continued safe operation of a steam locomotive with some of its systems malfunctioning, or even the safe braking distance of a train weighing thousands of tons - with more weight onboard than normal on a given day and in rainy conditions, when the rails become slippery and wheels are likely to slide.
From the 1830s through the 1940s, there were no onboard train radios to communicate among crew members or with the dispatcher. Unique operating situations often were not covered in the rules explicitly, and so crew members had to fall back on mutual understandings of the more basic rules - such as those for clear communications.
Engineers and conductors worked (and work today) independently and far out of sight of direct supervision by the railroad company hierarchy. Their responsibilities are exactly comparable to those of airline pilots. Railroad operating people took tremendous pride in their trades, stemming from their daily responsibilities.
Operating crew members (engineers, firemen, conductors, trainmen, dispatchers, station agents involved in telegraphy and train orders) all had to take annual classroom instruction and pass annual exams on the operating rules and other safety rules.
The earliest railroad 'rule books' were issued in the 1830s; 'rule books' of railroads today fill full-size binders.