I have been there with weight. I am older than you and I didn't gain the weight as quickly as you, but I did get as big as you by my late 40s, and struggled with it ever since. And while I have had periods of inactivity, that has been more the exception than the rule. I did Martial Arts, as well as jogging through high school, then jogging and weights through college into my mid 20s. Then weights and cardio classes such as Reebok step in my 20s through early 30s, then back to jogging and cycling, then more classes, and now a mix of Tae Kwon Do, cycling, and weights currently.
I can tell you from experience that exercise only accounts for maybe 15 or 20% of the total equation, and what you eat and other lifestyle factors like do you have a physically demanding job, do you drive to get around or do you walk, etc...Simply put, you can be somewhat active and still carry too much weight, if you are eating more calories than you burn. It helps to start keeping a food journal, so you know what you are eating. It shouldn't take more than a couple of weeks to figure out how much you are eating, then making changes to get your weight down.
I took up Tae Kwon Do 2 years ago with the goal of training for the mental and physical benefits, and they were pretty substantial. But as of June of 2019, my weight was actually about 10 lbs higher than it had been when I started TKD in February 2018! How was that possible? When I first started TKD I lost a little weight, but somehow, I adjusted my eating to make up for the calories I was burning off in my training. In my case, it was too much food overall, but especially too many refine carbohydrates like white bread, pasta, potatoes, rice and especially, sugar. By identifying the biggest offenders and eliminating or severely limiting them, and watching portions of the rest of my food, I have taken off almost 55 lbs (25 kg) since June. My training hasn't changed much but my weight is down because I changed my eating.