I’m not sure if you’re looking for a more detailed answer but here goes.
What a person eats does matter, regardless of it being the same amount of calories. A person eat 12 bags of hot Cheetos won’t get the same amount of nutrients as the person eating the fruit breakfast, burrito lunch, and salad dinner. The person eating three different meals is gaining more protein, fiber, carbs, and other essential nutrients. 12 bags of hot Cheetos is a lot of sugar, sodium, and empty calories. There’s nothing good in the hot Cheetos as compared to the other persons three healthy meals.