Dose of Halacha writes that there are 2 issues - 'sefiyah' and 'chinuch'. He brings sources that allows you to have a young child (too young to understand) do melacha:
The Gemara (Sukka 42a) writes that parents are obligated to teach and train their children to do mitzvos before they become bar / bas mitzva. This obligation, chinuch, only applies when a child is old and mature enough to appreciate what they are doing and why. The Mishna Berura (128:123) writes that with regards to most mitzvos, the age is approximately 5 to 6.
The Gemara (Yevamos 114a) writes that adults mustn’t feed children non-kosher food or make them do things that are forbidden on Shabbos. The Shulchan Aruch (OC 343:1) writes that this prohibition, known as sefiyah, also applies even if they are only forbidden miderabanan. Nonetheless, this only applies if the adult is specifically instructing the child to do the prohibition (See Mishna Berura 343:4).
The Shulchan Aruch Harav (OC 343:10) writes, however, that one may give things to a young child on Shabbos even though you know that they will do something that is forbidden.
Thus, R’ Yisroel Dovid Harfenes (Nishmas Shabbos 7:479) and the Piskei Teshuvos (343:2) write that one may stand a young child in front of a light switch on Shabbos even though they will switch it on or off, providing that they are too young to comprehend what they are doing.