One of the big issues with vending machines historically has been cash handling. It's expensive and time-consuming to pay people to empty the machine of cash, and the machine has to resist attempts to break it open - the cash is a more tempting target than the product. Now, with contactless, it's easier to produce cashless vending machines, although for rail use they would need to be capable of authorising the card "offline", as otherwise it would refuse service in phone coverage blackspots.
Having worked on the design of coffee machines in the past, they are an absolute engineering nightmare because the internals clog up with coffee grounds, milk powder, chocolate powder, etc. The good ones (like the Costa machines) require a surprising amount of attention from site staff, and regular visits from visiting maintenance engineers. The only truly reliable machines are those that use a disposable pod or pouch, but these then generate lots of plastic waste... I do agree with a previous poster that the Lavazza ones make the nicest coffee though!