This is part of the history of rail transportation by country series. They were introduced in Japan for passenger transportation. This made life a little easier. The simple answer for why they were built by the shore would be because it’s more convenient and make travel easier.