Weight gain is basically a matter of three factors. I suspect that at least one of these has changed for you.
Food intake
Human beings are very bad at monitoring their food intake. You may think that you're eating the same things in the same quantities, but you probably aren't. The easiest thing to do is to grab a notebook (or your tablet) and any time you eat or drink anything, note it down (with quantity if possible, even if it's a rough measurement). I would wager that you're taking in more calories than you think in the form of snacks and meals (even seemingly healthy ones). Don't forget to include alcohol consumption (I don't know where you reside, so I don't know if you're of a drinking age), which often throws people off with how many empty calories are involved. You may also find that you're snacking more often, "programming fuel", and those calories add up too. I know that, on my desk, I have a jar of peanuts. That's 160 calories per ounce, and it's easy for me to consume handfuls when I'm tracking down a bug.
Exercise
You may not have been doing any sort of structured exercise, but you may have been doing more incidental exercise, whether it was walking to and from school, or doing more stairs. Don't underestimate the impact of walking a few hundred feet each day to get to the bus, particularly if it involves impromptu jogging when you realize the bus is about to pull away. I'll be honest. Exercise has only mild effects on weight gain, but what it does do is help shift your weight toward more healthy tissues, muscle and bone instead of fat.
Basal metabolism
The ugly truth is that our metabolisms do slow down as we age, and the early 20s is one of the places people start to notice it. You can get it up a bit through moderate exercise, but otherwise, it's basically dependent on your height, weight, and age. There really is no way to boost it, despite what all of the magic herb companies would like you to believe. There are no fat-burning pills. There's some evidence that longterm sedentary work can also reduce it, although it's hard to separate that out from diet and exercise.
Summary
So, what to do? It's really pretty simple. Start some mild exercise, even if it involves getting up and walking around the neighborhood at night. Try to find something that's fun for you. Sports can work for that too, even something which seems purely recreational like bicycling or roller-skating. Try to find friends to do it with you. Try to cut down on excessive consumption of calories. This may consist of cutting down on sodas and having smaller containers of snacks on your desk so that you don't eat the whole bag of nuts over the course of a day. Basal Metabolism Rate, you can't do much about that, but there's evidence that measures as small as standing up once every 20 minutes or walking around for a minute every hour on the hour are enough to nearly reverse the negative effects of prolonged sitting. Personally, I combine that with getting up to refill my coffee mug and/or water bottle. As a bonus, as a programmer, I find that stepping away from a problem often gives me some new insights (although, caveat, you need to make sure you're not in the middle of something that will take you 20 minutes to get back into).
Good luck! The fact that you're asking questions is a good first step.