Costco is not usually the cheapest option in the areas where they have their stores, since other nearby stations normally match their fuel pricing, or Costco is forced to match nearby stations that sell plenty of high markup snacks and drinks and a Kroger or a Speedway or a BP using their loyalty cards often ends up a penny or two cheaper, although Costco is always among the least costly choices for fuel. Remember also that they all pay the same wholesale price for fuel if the station has enough volume to take a full tanker of fuel at least a couple of times a week.
Costco is also serving a different market. People don't stop at Costco for a quick gas and go and maybe a pop.
OTOH, a lot of people will stop at Speedway on their way home from work and buy a little gas along with maybe a pack of smokes and some brews and are in and out in less time than you'd spend waiting in line for a pump at Costco, and buying anything at Costco is not a quick and easy process.
Speedway has not been the low price leader in this area in a number of years, but whenever I drive by one they always seem to have a fair amount of traffic. Costco does as well, but those buying gas are usually planning an hour or two inside the store stocking up for the apocalypse.