When you first start a new gym routine, you usually gain weight before losing. This is because your body is gaining muscle whilst losing fat, and muscle weighs more than fat. Also, you haven't really gave us very many details. Have you changed your eating habits? If you're drinking 10 sodas a day, and only going to the gym for 20 minutes, well, you won't lose any weight. Just because you go to the gym, doesn't mean you'll lose weight. There are a lot of factors in the whole weight loss world. What are you doing at the gym? How long are you going? What are you eating?
Well maybe you're eating junk food? Even if you go to the gym everyday, but you eat junk your gonna gain pounds. Not as many but you will. With a combination of eating healthy and exercise, then you shouldn't gain that much weight. Also maybe it's the Muscle, not fat
I have went to the gym for years and never once did I gain weight... I am also not on a strict diet but I walk 3 miles a day as well as exercised at the gym for an hr, once a week I do Zumba...may sound like a lot but it becomes part of your life, you make time for it. There are lots of reasons as mentioned but also have you started any new medication. Antidepressants will put the weight on quick.