In my area Costco gas is usually the cheapest, but it's not always the cheapest by amounts like 50 cents. Its usually more on the order of 20 cents cheaper. The next cheapest stations share some similarities with Costco though -- they all tend to be unbranded gas stations. These don't usually have the agreements that branded stations have, where they have to buy a certain % of their supply from the brands refineries. So Costco tends to be buying the cheapest gas available at the time, has no brand-name overhead, and on top of that, purposely keeps their profit low to get more people joining. Another thing that Costco does, not just with gas but with everything, is they only accept their partnered credit cards. Their merchant fees are likely much lower, and as Costco does, they just pass that onto you.
So Costco is paying less, and keeping less (if any) profit. The net result is that their gas is appreciably cheaper.
So Costco is paying less, and keeping less (if any) profit. The net result is that their gas is appreciably cheaper.