There were many reasons for this expansion. We will look at two of the most important reasons here.
First, the expansion came because steel could be made more quickly and cheaply. The Bessemer Process allowed this to happen, making railroads much more affordable.
Second, the expansion was made possible by the Civil War. With the secession of the South, there was no longer any opposition to laws that would help a transcontinental railroad be built across the North. Congress was able to pass laws giving the railroads land grants in return for the construction of the lines.
So, the railroad boom was made possible by technological advances and by the changing political scene caused by the Civil War.