Where did I say that it was necessary? In the US there are lots of major ports all along the coast, which is where most of the population is. For the Pacific:
Nitpicking: Switzerland actually does have three ports that provide, protected by international law, access to the North Sea (via the Rhine) and the Black Sea (via the Rhine–Main–Danube canal). In terms of quantities, about 10% of imports are going through these ports, mainly bulk load.
* https://en.wikipedia.org/wiki/List_of_Panamax_ports#Pacific_...
And from any of those it's probably not that far to any major population centre.
Compare to Switzerland, which has precisely zero ports, and so of course needs rail (and trucks) to get things delivered.