It is to stop items from accidentally getting charged to the wrong person. It benefits both people. I never expect a thank you for doing it. If something gets charged to the wrong person, everyone gets screwed. You, the cashier, and this idiot. Now everyone has to wait for the cashier to void the transaction and call a manager over. Congratulations, you played yourself.
They can just go get the thing they’re missing, they’ve lost nothing but you’ve wasted money in some weird senseless vendetta that only you suffer from.