hi mummy
If I had walked into a chemist and was greeted by a 4 year old who said that to me I would be absolutely horrified and think how incredibly rude he was. You keep telling us, "he didn't know what he was saying...." But he clearly did seeing as he said it in an appropriate context. My niece is 4 and she would never say anything like that to anybody, adult or child. She hasn't learnt the 'art' of sarcasm yet and if I was the lady in question, I would be more horrified at his ability to be sarcastic than what he actually said. If he is clever enough to come up with that line, he's clever enough to understand the basic concept of not being rude.
She genuinely may not have known he opened the door for her. It may have been her first time there and not known the doors could be opened electronically from the inside. If I approached a door that suddenly opened I would assume they worked on sensors, my first thought wouldn't be to scan the area to see if a child had activated them for me. I know you said the doors were glass but if the button was a meter away and not something that had a flashing neon 'push me to open the doors' sign above it then there is no reason to assume she may not have seen it. Especially if her mind was distracted by news she'd had from then GP.
If it had been me in this situation and I knew the child had opened the door for me I wouldn't necessarily say thank you because I would assume he was doing it for his own amusement, because he liked playing the doors and not because he was having the thought concept of, "I'm going to be helpful for other people." And like I said, if a child then spoke to me like yours did I would have been astounded.
However, I would not have shouted/snapped at the child. I would though be glaring at the mother and would fully expect to be apologised to and see the child chastised for having said what he did. I wouldn't have stormedmputmthemchemistmthough, I'd probably have started a full loan row with you after having been shouted at! I can understand why she scarpered though, how utterly humiliating for her.
So, in my opinion, YANBU for being shocked and unhappy that the woman snapped at your son and I don't think you were BU for letting his push the button, there's no harm in it if he can't hurt himself and the shop doesn't have a problem with it. However, I do think the way you dealt with it was wrong, but it was probably your knee jerk reaction at wanting to protect your son, which I can understand.
We all mistakes though, I'm sure you have spoken to your son now and hopefully you will never have to be in this situation again 