I recall reading that part of why Japan has more vending machines and more variety is the ownership model. In the US vending machines are typically run by companies that service them and collect the revenue. But in Japan, they're typically owned by the shops. So shops are more likely to put a variety of products from their store in the vending machines.
I also suspect a higher incidence of social anxiety increases the demand for them in Japan.