Motorway service stations tend to be remote(ish) locations, they have to get water and electric to them, and sewage away from them. This costs a lot to put the infrastructure in place. This has to be recovered.
Service stations are not allowed to advertise, nor are they allowed to be destinations in their own right. So they can only attract passing traffic (literally!)
They don’t shift huge quantities so can’t buy stuff as cheaply as supermarkets, as they simply don’t buy the quantity.
On both services and train stations, most outlets are franchised. There’s one company who owns most of them, many companies (M&S and McDonalds and Subway in particular) insist that the same prices are charged for the same item, regardless of where it’s purchased. Other companies (KFC, Burger King) allow different prices for at least some items. Greggs does too, but too a much lesser extent, but you will find slight variations in a few Greggs prices.
Most train station and service stations make very small profits though. The high prices aren’t greed, but necessity for them.
Of course, the flip side is, are supermarkets actually too cheap? The reason we feel these places are dear is because we compare them to supermarket prices.