You seem to be implying that railway spending was "over 10% of GDP for a few decades" in the late 1800s. If yes then can you trace that back to a methodology? I tried and found much lower numbers, around 3% average over the peak decade.
https://news.ycombinator.com/item?id=44805979
Your estimate of current AI spending is also low. Hyperscaler capex alone is around 2% of US GDP, not including other costs (neoclouds, employee comp, etc.).
You're right, I was remembering the peak and duration of the railway boom but of course it wasn't at the peak for the entire duration.