It's actually in the membership agreement. If you refuse to show, they can ban you. However, the fact you would have a Costco membership indicates that you signed an agreement that allows them to have you show the receipt.
In my experiences, it has always been something flagged by the receipt checker at Costco confirming that I got something I paid for and had to collect for the secure area, or provided to me at check out like movie tickets.