The idea of joining the gym is so you can see some great changes in your body. People already struggle with deciding to join a gym and adopt a healthier lifestyle. But what keeps most people going is the positive feedback they get as they keep at it. It is therefore disheartening for most people to realize that they have gained weight!
It is actually quite common for people to gain weight the first few months they join the gym. You will not manage to sway those people back on track when they see they are achieving opposite of what they wanted. You can see why explaining to them why this is so is critical to them retaining their gym memberships.
You may be undergoing water retention. Exercises are a significant change in your life. Exercises tend to cause muscle fibers to develop tears, as you build more muscle mass. The body reacts by retaining water. It is only temporary, so no need to worry. Drink lots of water, eat well, and get enough sleep.
The reason may be glycogen conversion. Your body turns glycogen into glucose to produce energy. The more you exercise, the more glycogen you get to store as fuel for the upcoming exercises. Glycogen needs to bind with water to fuel the muscles. The more you stick with the exercises, the more efficient your body gets thus needing less glycogen for energy. You end up retaining less water, thus attaining the weight loss goals.
A high-calorie diet could also be the reason. As you exercise to lose weight, you need to be on a caloric deficit diet. Out lives are chaotic to the extent that monitoring our caloric intake is almost impossible. It is impossible to lose weight if you keep taking in more calories than you burn. At the same time, taking drastic measures such as an extreme reduction in calories leads to failure since it is not sustainable. Reduce it gradually over time. You also need to eat more whole foods than processed foods.
You may also be affected by time. It took you a while to gain all that weight. Losing it will also make some time. The body will try and fight your intentions with coping mechanisms. If you decide to exercise more often, it will find a way to counter those gains. There is a need for patience and discipline in the process.
You may also mistake muscle gain with fat weight gain. As you work out, you will gain more muscle mass. Weight gain will still register on the scales even when you no longer fit in your clothes. You should be happy with such a weight gain, as it is all lean muscle, not fatty deposits.