>>/18838/
Railroad was (and sometimes is) the main method of transportation for large distances. It allows to transport large amount of people, vehicles and cargo very quickly, it gives quick reaction response.
So, it is like "why fight in cities, you can avoid them, they are big and immobile". But: 1) how you will control territory when there are hostile city 2) why even occupy something if not cities?
People also underestimate mobility problems, especially until mass mechanization. Large group of troops without vehicles couldn't easily move more than 30-50km in day. Railroad allows you to push troops at same distance in few hours (considering loading and unloading). So, while your forces slowly march through forests and swamps, enemy would move his troops to prepare defense or to strike you in back. Large regiment of troops that want to cross railroad couldn't easily avoid these trains: while they slowly gather near some point, train could easily move there.
Most of these arguments may be applied to common roads too, but until mass automobilization (~1930-1950 for armies) roads weren't so good as railroads for transportation. Transporting heavy artillery also was problematic task: even now naval artillery, for example, are much more sophisticated and effective that land-based because ships allow guns to be much heavier.
So, armored trains were a thing. Of course they weren't a superweapon, and in large scale wars (WW1, WW2) they were required, but not main part of forces. In low-intensity civil wars and anti-partisan operation they were much better because both sides didn't want to ruin rails and cities, but only to control them. And these trains provided fast response to threats and good protection against partisan forces who try to hijack trains. That is why armored train cult was formed in Russian Civil war, not in WW1 or WW2.