I am going through an online course on inferential statistics, they ask:
I do not agree that the independent variable is kids' ages - because of the experiment design, they themselves have picked kids of ages 4 and 8. Yes, the actual ages will diverge a little bit, but still, I would not call it an independent variable.
What I would call independent is the number of sentences a kid says [ideally, the number of words a kid uses but they do not give such an option] because that is indeed random.
Could you explain their logic behind the answer if you agree with it?

I agree that the answer should be the kids' ages.
The number of sentences produced by the child is not random. Four year olds cannot produce long sentences because their brains have not developed enough to say long sentences, whereas eight-year olds have better language ability.
It is helpful to think of the independent variable as 'the variable you can change/directly influence'. In this case, the researchers can choose the ages, such as 5 and 12 if they wanted to, but it would be much harder to invite a four year old to speak for longer.