Why the trolley does not decide
Card rewards are paid against a merchant category, not against what you bought. Every merchant is assigned a category code by its payment processor, the issuer maps that code to its own bonus categories, and the rate follows the code.
Target's code puts it with discount stores and superstores. Walmart usually sits in the same group. A card paying 6% or 4x on US supermarkets sees a superstore, not a supermarket, and pays its everything-else rate instead.
This is why a cart of nothing but food at Target earns less than the same cart at a supermarket across the road. Nothing has gone wrong; the category was decided before you reached the till.
Which stores usually do count
Standalone supermarkets are the reliable case: Whole Foods, Trader Joe's, Kroger, Publix, Safeway and their regional equivalents generally code as supermarkets and do earn grocery bonuses.
The usual exclusions are superstores (Target, Walmart), warehouse clubs (Costco, Sam's Club, BJ's), and meal-kit or delivery services, which often code as something else entirely.
Groceries bought inside a store that is not a supermarket, such as a pharmacy or a petrol station shop, take that store's category too.
What to use at Target instead
With no category bonus available, the winner is usually whichever card pays the most on everything: a flat-rate 2% card beats a 4x grocery card earning its 1x base there, by a wide margin on a large shop.
Target's own store card pays a discount at the register rather than a rewards multiplier, which is a different kind of benefit and worth comparing against your flat-rate card on price rather than points.
The practical rule: at a superstore, stop thinking in categories and reach for your best everything-else card.