Walmart near me has started using receipt checkers lately and they don’t even really do their job, it’s kind of a gimmick really. They just look at the receipt for a second Don’t even look at your cart, but they stop you every time. It’s just such a waste of my time when I’m in a hurry. I had one person even tell me that it was required by law. No it’s not! There’s no law in the USA that says they have to check your receipt.
Costco requires a membership so it’s likely in their terms of service that you have to consent to their checks. Walmart does not, so you can refuse without any recourse.