It depends on the time an place.
In places like Europe Railways were built to connect cities that had existed for a long time.
In place like the American West frequently cities sprung up alongside railways.
In North America you have to separate out towns and cities that were founded before Railways were a thing, while they were the primary mode of long distance transportation and after they were replaced too a large degree by trucks and cars.
In the days before rail was wide spread, large cities tended to spring on costs and rivers, because humans need water and because boats and ships were a way to transport goods in bulk before the railway was a thing.
In the US in the beginning rivers like the Mississippi and its navigable tributaries (the rivers the flow into it and are big enough to allow boats to move though them) form a natural transportation network and many cities have sprung up around it.
The American West lacked such convenient natural transportation networks. When the railway was built to connect the East coast to the west coast it naturally passed by many existing settlements that grew because goods and people could now easily get there.
Some new settlements sprung up around the railway where none existed before, to take advantage of the railway.
If you have heard of the Donner Party or the Oregon Trail you may have some idea that traveling to the west coast over land was a long and difficult thing, that a person might do once in a life-time.
Before the railway was built to connect the east coast to the west coast, the easiest way to transport people from for example Los Angles to New York was to take a ship down to Panama travel across that country over land and take another ship up to the east coast of the US.
The railway made direct travel from one part of the US to another much easier cheaper, faster and safer.
If you were on the railway you were part of the country and could ship goods out to elsewhere and receive goods from elsewhere.
It wasn’t until the US highways system was built that transporting over the road was a viable alternative.
Latest Answers