So if I'm eating 4000 cals a day of just any food with little weight gain and change to 3000 cals of clean food I will still gain weight?
Well as a simple answer, yes.
Your muscles need certain amounts macro nutrients and micro nutrients to have optimum growth. Furthermore, high processed foods break down much, much faster than whole natural foods. The fast breakdown means a few things:
1) Your body treats these macro's almost like simple carbohydrates. It breaks down the food faster than your body can absorb the nutrients meaning a large portion of the food gets stored as fat. This is especially true for those who are not very active as compared to the average activity level.
2) The lack of fiber and other key micro nutrients in the foods also means that your body has a harder time with nutrient partitioning, thus, less calories are actually utilized for muscle fiber growth.
3) Because of the fast digestion, you get hungrier more often - which means you eat may eat more frequently - which may also mean that you bring in way too many empty calories at the end of the day causing even more fat storage. *** Granted, this would not be so true for someone who is generally in the normal range of daily activity (aka lazy). The typical American who eats fast food twice a day for a whopping 3000 total calories has a different situation, but the same root cause. Due to lack of activity, poor nutrients and nutrient partitioning, and too many total calories, their body's metabolism slows down significantly which also provides greater reason for the food to be stored as fat since the body is generally inactive. Regardless, either way starts with unhealthy, processed foods.
At the end of the day, we eat whole foods, organic foods, food high in fiber, foods low in simple carbs and high in complex carbs, and foods really high in protein all for the same reasons - slow digestion, usable nutrients and good nutrient partitioning.