If you take in more calories than you burn, you will gain weight.
I agree that this is a true statement. However, it's not necessarily the only factor which may cause a person to gain weight. There can be other issues at play (such as an imbalance of hormones) that can cause a person to gain weight, even with the proper diet and exercise protocol.
It can be a very frustrating process to figure out exactly what the underlying cause may be.