If the lights went off in a home, and a child understands that his parents would be pleased if he would turn them back on, the parents must tell him not to do so. As we have already learned, parents have an obligation to educate their children to keep the mitzvot, and this includes preventing them from transgressing prohibitions. Even if a child is not yet three years old, which is generally the age at which we begin teaching children to avoid prohibited activities, the law is more stringent for Shabbat. As long as the child understands that turning on the lights would be helpful to his parents, it is as if he is doing it for them, and they must prevent him from doing it, based on the verse we cited above: “But the seventh day is a Shabbat of the Lord your God; you shall not do any melakha – you, your son or daughter” (Shemot 20:10). This means that we are commanded to make sure that children do not perform melakha on our behalf. Even if the lights went off in a neighbor’s home and one’s child goes over to turn on the lights for them, the neighbor must not allow him to do melakha for them.
Similarly, if a fire breaks out on Shabbat and a child attempts to put it out, whether at his parents’ home or at someone else’s house, he must be stopped from extinguishing it. Since the child understands that the adults want the fire to be extinguished, he is essentially doing the melakha for them, and thus they are obligated to tell him not to do so (Shabbat 121a; SA 334:25; MB ad loc. 66). Certainly, then, one may not tell a child explicitly to turn on a light or extinguish a fire; as we already learned, an adult may not cause a child to do anything prohibited (Yevamot 114a).[2]
Of course, if a child mistakenly turned off a light, it is important that no one yell at him in a way that will cause him to try to “correct” his mistake by turning the light back on. Even if no one yelled at him, but he simply wants to correct his mistake and turn it back on, he must be told not to do so.
If a child mistakenly performed a melakha on Shabbat (such as turning on the light), others may not benefit from it if he did it for the sake of an adult, but if he did it for his own sake, others may benefit from the light (BHL 325:10, s.v. “eino yehudi”).