Isn't this statement kinda backwards though? Surely the big cities developed along that line due to the natural geography (flat land, near bodies of water and with protection from the mountains) and then once trains first came along, it made sense to connect those cities. It's not that people happen to live within 5km of the trainline, but that the trainline was built there because that's where people lived.
Not as big a portion of the country, but yeah coastal areas will often have a large population living in roughly a line.
In North America I believe the line connecting the most people would go from Quebec City through Montreal, Ottawa, Toronto, London, Detroit, Chicago, Milwaukee and Minneapolis (though maybe not within just 5 km of it). This is the most populous part of the Great Lakes Megalopolis and into the St. Lawrence.
You’re absolutely right. That train runs across the Swiss Plateau with mountains either side of the plateau. Historically, if you were going to grow any produce, that was where you would grow it so it’s no surprise there’s such a density of people in the flatter part of an extremely mountainous country.