Yes, if calories in > calories out then you will gain weight.
There are significant factors which affect both how many calories your body will take in, as well as how many it burns out, even if two people have identical activity levels. So while that "calories in vs calories out" statement is true, it's also trite. Faster metabolisms or better metabolic efficiency can lead to lower weight gain than another person might experience for a given level of activity.
It is useful advice on an individual scale - you yourself cannot directly affect your metabolism or your gut biome at the present time so the only thing you can really affect is exercise and caloric intake. It is not predictive between persons in the sense that two people on identical diets and exercise regimes will experience identical amounts of weight change.
Fecal transplants are an interesting wildcard - the idea is to kill off your own gut microbiome as much as possible and then replace it with someone else's. In some case studies, this has had significant efficacy in weight loss. My understanding is these fauna have significant effects in "pre-processing" this food as well as consuming some of the energy for themselves, so yes, microbiome can directly affect weight gain/loss.