Because browsing isn't buying. You absolutely can go into a gym and check it out without a membership.
Edit: Expecting me to buy a Costco membership before I can see things like whether or not they're keeping the place clean and their produce fresh is unreasonable in my opinion,
You can go as a guest with someone who has a membership. As far as I know, if someone gives you a Costco gift card you can go in without a membership. If you tell them you are there to consider a membership, they at least used to let you in. But you can’t buy anything without signing up.