They absolutely know that the person they're having a go at can't change anything and has no say over it, and likely is ignored anyway if they do feedback, but they're frustrated at not getting what they want immediately they demand and clearly not emotionally intelligent enough to deal with that feeling and therefore unload it onto someone else who they know can't defend themselves.
It seems to be becoming the main expectation of customer facing staff - being the public's emotional punch bag. They are human, it takes it's toll eventually.
And ironically it's just going to make the issue worse because less and less people will want to work in that environment (hospitality is well known to be struggling for one) and that's going to a) push wages and therefore prices up and b) mean even less staff available to actually do the job and more automation.
People need to learn to deal with their own emotions and stop being so dramatic, you don't need a life changing experience to buy a pint of milk, if you don't like the self service fine, just decline if you're offered to and if there's no other option then don't shop there again. Complain like a grown up to head office.
Being snarky and arsey with the floor staff is going to change precisely nothing, and as said, most people know that. It might be what makes them move out of the job though and into something else and the industry be another worker short.
Shops and companies need to change, but so does customer behaviour. I hate the saying 'after covid' but certainly since covid people come at you with a combative attitude from the start, before they've even had any kind of interaction. People need to take responsibility for their own feelings and behaviours instead of shirking responsibility because they're a 'customer'.