Americans who truly respect their own freedom need to understand the limits of what private security can legally do on private property. You're basically not obligated to do a damned thing they say except leave the premises. Any private citizen who attempts to detain you should soon wish they hadn't.
While I agree that the security guard was most likely out of line, the fact that the store had a security guard at all means they are having a problem with theft there.
Where I live, the supermarkets don’t have security guards, and often when my children were little and got cranky, I would let them eat some crackers while we were shopping, and of course buy the crackers.
But if the store had had security guards, I would know it was a low-trust high-theft situation, and not let them eat anything we hadn’t paid for yet. Bring a snack from home instead.