Calories In - Calories out is the only thing that matters. Yes you'll gain weight. But as you gain weight, your calorie expenditure per mile increases because you're doing more work (Work= mass*acceleration*distance) and your mass is increasing, so you'd eventually reach equilibrium unless you continue to eat more and more calories.
That being said, men tend to gain weight as muscle, which works towards injury prevention and force output, where women tend to gain weight as fat, which is counterproductive in almost every way unless you're currently underweight, in which case your immune system will be stronger and you'll be less injury prone.
Either way, professionals tend taper their weight the same way you taper your mileage and workouts. At the end of the season, Centrowitz looks like a twig compared to where he's at through all of indoors and most of outdoors. Just watch the 2016 Rio Olympics, he's tiny. In his post-race interview after 2012 Olympics he even says he thinks he overdid the weight loss leading up to the race, and felt a bit drained.
It's better to train a couple pounds over race-weight for most of the year and have the extra injury prevention than try and red-line for the sake of feeling more fit in your workouts. Racing weight is a great book by Matt Fitzgerald that goes into all of this and the proper way to reduce bodyfat without affecting performance.