It’s possible with a lot of thought and preparation.
I didn’t start writing until my kids were in high school, so it was easier for me. But when my son moved back home with his toddler I ended up caring for my grandson so I found myself facing the same problem.
I was cunning. I cheated. I used the TV as a babysitter.
Since the kid programs usually come on about the time school lets out, that was my ‘writing’ time. I turned on the TV, made sure there were snacks and toys available, and sat down at my desk that was in the same room but at the back and as far from the TV as possible so he wasn’t tempted to talk to me unless it was necessary and it worked.
I don’t know if that particular method would work for everyone, but where there’s a will, there’s a way and most authors I know are canny enough and smart enough and creative enough to figure it out for their situation.