Is it okay to correct someone else's kid?

So, a few months ago I was at McDonald's with my daughter. She was playing in the play zone and there were a couple of other kids there, probably about 2 and 4 years old. They were playing on their own while the parents were out at the counter getting food. While watching my daughter, the older of the 2 kids got a plastic bag and put it over their brother's head. I just got up and took the bag off of his head and explained to them that we don't play like that because it's dangerous then threw the bag out. I didnt mention it to the parents because I didnt want to cause a fuss, but was this the correct way to handle this?