The key here is that OP has paid for their groceries. Once the transaction completes, the groceries are their property. OP has no obligation to prove to anyone that they own their own property after that (except in the case of Costco and Sam's club, which you of course don't have to prove either, but they will revoke your membership if you don't). In your scenario, you haven't paid for the groceries yet. So they are still the store's property. And they can of course take measures to protect their property while it's still in their possession.
Receipt checking, by definition, always happens after the transaction has completed and the payer has taken possession of the groceries, hence the receipt. So receipt checking is always a practice to verify that your already lawfully purchased groceries match up with what you are removing from the store. This is a practice, while rooted in a perspective that benefits the store, that you have no obligation whatsoever to comply with.
The store, as mentioned above, has no obligation to let you back into the store (they can ban you), but they also have no right to detain you and force you to prove that you own your belongings as you are leaving either. And a store is not going to ban someone unless they are completely sure they have stolen something. So in practice there is really no issue with telling receipt checkers to pound sand for trying to verify my lawfully purchased groceries. I usually don't, because it feels standoffish for no reason sometimes, and you risk encountering someone that doesn't fully understand the law correctly. But if I have a good reason, as mentioned above, I will definitely tell them to pound sand.
I realize now rereading the thread how these two scenarios became conflated, because OP responded to the "before purchase" scenario that you provided with an "after purchase" scenario. So we are really talking about two different scenarios here.