Healthy foods do not necessarily mean are a magic potion to lose weight or to gain muscle. Natural foods are generally lower in calories because do not contain all those extra fats and sugars that are used when they are processed.
The micronutrients (vitamins and minerals) that offer healthy foods (unprocessed) , has no competition when offering the body the satiety that it needs to manage calories in the system wisely.
Effectively, calories in vs calories out determines; if losing weight or gaining weight.
Gaining fat or gaining muscle depends of the physical activity done. Losing fat not only depends of using (burning) calories. It depends of building muscle (resistance training) so that whenever the body eliminates energy from the deficit created can mostly go from fat since has no reason to be hold because resistance training holds the muscle by stimulating it to a growing phase.
Knowing how much energy (food) is coming in is important to achieve a weight goal.
It is like money coming in to the bank account. It is important to know before spend it. To build muscle (gaining weight) if you're very active during the day, you are already using calories (expending calories). Strength training will tell the body to grow, but with out the calories needed, it will be impossible to complete the process. Also if calories do not come from where they can complete the biological process our body wants (proteins) it will be hard to make it grow.
Calories in vs calories out matter, BUT where those calories come from dictate the efficiency to continue.