Someone did a study (some time ago - can't remember who or where) where they let babies choose from a selection of foods set out in front of them which and how much they ate. They recorded what each chose and totted them up at the end of it (it went on for several days). They concluded that they chose different amounts of different things at different times, ans sometimes a lot of one thing for a while, but the overall diet was a good balanced one.
On the strength of this kind of experiment, it seems to be assumed that they know what they should be eating. Admittedly, if they don't want it and won't eat it, then the best diet in the world is not going to do them much good, but it does depend on the foods they can choose from being a good selection to start with. They can't decide to go and buy X because that is what they will want to eat today.