You meant well.
That counts for something, but...you can't undermine a parent's authority. You giving the child the candy, especially without asking the parent's permission, makes the parent's judgment seem unreasonable in the eyes of a young child who doesn't realize that their parent isn't being mean but is doing/not doing allowing/not allowing something for the child's own good. A very proud person might feel offended by your act of kindness. To them it might seem as though you were offering charity and that can be insulting to some. Some people will figure that you're doubting their ability to provide for their own child.
Children need to be taught that throwing tantrums (was the kid throwing tantrums?) is neither appropirate, nor will it get people to comply with their needs or wants. I will not jump and comply to every demand my child makes as soon as she starts screaming or crying. That is unreasonable and it will seriously spoil her character. Kids have to be taught that 'no' means 'no' and that they cannot always have everything that they want. Often times, it's difficult enough to raise a child and teach them. Then there are people who may mean well but they don't help at all. You have kids, I'm sure you know what I am talking about. Most people who don't have kids probably think that the woman was being mean or unreasonable. It easy for those kinds of people talk about what others should do with their kids when they themselves have never raised a child. Also, with the gift giving...my sister-in-law was telling me how it's not wise for a person to give stranger's kids gifts or buy them things because kids have to be taught to not accept gifts from strangers. For saftey reasons,of course.
My child was throwing a fit in the store once. So, at this point she is crying just to cry as toddlers tend to do when they don't get their way...some complete stranger comes up to her and starts trying to talk to her! I'm standing there thinking WTF? What is the point of trying to teach my toddler something when others are going to come and **** it up? A parent has to show some consistency. When you say something then you have to stand by what you say if you want your child to have some sort of stability. You have to set limits and rules for children. Not overly harsh, but limits are necessary so that a child knows what they can and cannot do. I tell my child that she's not going to get any attention when she throws fits, and this guy comes up and starts talking to her. I had to tell a woman off once becaue the bitch was rudely insisitng on underming me in front of my kid. Someone has to piss me off royaly before I get to that point. That's a story for another day.
I think you're a kind person, probably good with kids, but even a kind gesture could have and adverse effect. It's very likely that the woman returned the candy after you left and the kid ended up even more disappointed. It's also possible that the kid now thinks of her mother's actions as mean and unjust. Unless someone is hurting a child, you should never interfere or assume you know what is going on.