What factors contributed to the expansion of railroads in the United States during the 19th century?