On days I go for a hike my belly bloats way huge and I get a lot of water retention even though I often eat foods that have no salt added and drink just water. I don't worry about it.
I gained weight toward the end of my two PCT half-thru-hikes. I believe that lots of daily long endurance-style cardio is actually not very good for your health, and neither are typical foods eaten when hiking. I have switched over to weight lifting 2x a week plus sprinting 2x a week on an exercise bike (22sec on, 90sec rest) and a hike 1x a week. I have the best-looking body of my life, plus I can squat more than my own body weight and pretty soon I will be able to do a pull-up, something I've never done before. Walking around with 22lbs on my back feels like nothing.