There are many unique vending machines all over Japan, including one in a train in Shizuoka (photo), and even one that has a car in it.
This is a famous photo .The train line is in the middle of no where and the seats are never filled up. The line is in the red and a vending machine is just an extra something to put a smile on the passengers faces.
The one in the train is very convenient. Imagine you're running late and don't have time for your morning coffee, or returning home from a busy day- warm/cold drink really comes in handy.