It's more as if Target would refuse to sell you a certain size of diapers unless you sign up for their credit card membership thingy.
Costco could run a parallel retail outfit (also visibly Costco branded, like "Costco Open" or something) where anyone can walk in and buy anything, but not some things that are available only in regular Costco.
There is an analogy here though: like a site refusing to run after detecting that your browser is running on Linux, such that if you fake that string, everything works fine.
Not true. Many years ago Atari patented a little cartridge flap just so no one else could make a cartridge that could be inserted into their platform. There are many other examples.
"Non-members may be assessed an additional surcharge for purchases (does not apply to prescription items)."