Citibank bent over backwards to get Costco. A few years ago Amex was the only card you could use at Costco. Citibank agreed to not only make a new card with better rewards to compete with Amex, but they agreed to honor all the reward points too. They just rolled over from Amex.
I'm sure Costco got a deal that gives them nearly at cost processing and a bunch of other stuff.
It was worth it for Citi too. The moment I got my Costco Amex replaced with a Costco Citi, the Citi became my primary card, because everyone takes Visa.