Answer: The Gemara (Sukka 42a) teaches that parents are obligated to teach and train their children to do mitzvos. The Mishna Berura (128:123) explains that this age varies between different children and mitzvos.
The Gemara (Yevamos 114a) teaches that one mustn’t instruct children to carry in a reshus harabim on Shabbos though one may allow them to do so of their own volition. Thus, Rambam (Maachalos Asuros 17:27) writes that the beis din does not need to protest against children who are eating non-kosher food or breaking Shabbos. The Shulchan Aruch Harav (OC 343:1) adds that one must prevent children doing a prohibited melacha for an adult, however.
The Mishna Berura (318:5) writes that if a non-Jewish person performs a prohibited melacha on behalf of a Jewish person on Shabbos then one must not benefit from that melacha on Shabbos, though wait the amount of time that it took after Shabbos. Thus, if they cooked something for half an hour on Shabbos, one would have to wait at least half an hour after nacht to eat that food (See Shulchan Aruch OC 325:6).
The Biur Halacha (325:10) quotes the Magen Avraham (325:22) and Pri Megadim (325:22) who write that this applies equally if a child performs a melacha on an adult’s behalf. If however, the child performs the melacha for their own sake then one may benefit from the melacha immediately.
In conclusion, while one would not normally be able to benefit from something cooked on Shabbos even accidentally (See Mishna Berura 318:7), if a child did the melacha for themselves, one may benefit from the melacha and use water they had heated.