Not everyone living along a coast has an appropriate coast to establish a harbor sufficient for shipping. If you live in big sur you still get your crap from china delivered inland from the port of Los Angeles.
* 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.
Source (only in german): https://de.wikipedia.org/wiki/Schweizerische_Rheinh%C3%A4fen