This is true, but only part of the story. The private railroads (and indeed much internet infrastructure) had two phases. In the first, early entrants made big profits by picking the low hanging fruit (i.e. most profitable opportunities) in a new market.
This created investor euphoria just as the opportunities for "easy" profits were drying up. So things turned towards speculative, even fraudulent investments that left the investors out of pocket. But, as you point out, even the second phase left some infrastructure on the ground that could be operated at a profit once bought at firesale prices.