You have two main errors: 1) conflating refineries with terminals 2) forgetting that fuel is a fungible financial product.
There are terminals all over the country, within trucking distance of the stations they serve. Those terminals can be supplied by a nearby refinery, yes, but also one or more distant refineries connected to a pipeline or via ship, train, or barge. There is an entire swath of the energy market called "midstream" that handles this.
Once a refined fuel gets into a terminal, its refinery of origin stops really mattering for contract purposes because of swaps. Exxon can supply gasoline in one market while Marathon supplies an economically equivalent amount somewhere else. Nobody is moving “Exxon molecules”. I mean, it literally all goes into the same tank if it's the same product. They (the terminal) just keep track of who supplied how much. The detergent package is also mixed in at the terminal loading rack, along with ethanol in the case of gas, not at the refinery.
Also, very few states actually have specific rules. California is the only real pain in the butt. You might be thinking of summer vs. winter blends, where the refiners adjust the vapor pressure to reduce emission in the summer and to increase ease of engine starting in the winter. This is something every refinery can and easily does.
Currently I buy Shell gas b/c I trust that it's good for my car's engine. Can I trust that Costco's gas is as good as Shell's?
If a gas station brand advertises Top Tier(tm) gasoline at all, every location must supply it. Diesel is location dependent and warrants more consideration.
All fuel sold at Costco is Top Tier.
I generally buy my gas at Kroger. I do buy premium as my car requires it. In some quick research just now I discovered that Shell is a major supplier of gas sold by Kroger, which bums me out as I have a long-standing personal boycott of Shell products.