This is due to two different factors: lack of planning with food choices, and a good old fashioned shortage of moving around.
I've worked a desk job for about 4 years, and so far, I've been lucky enough to have stayed pretty fit. But believe you me, I can see how it happens.
I try hard to do two things to keep me on track. First I bring enough healthy food to keep me going without an everyday candy bar trip to the gas station:
Pear, Apple, Greek Yogurt, Carrots, Pistachios, Tuna, and Dark Chocolate
About 800 calories, with good fat and lots of protein.
And second, I do little exercises in my office all day long. Which, you'll be lucky enough to watch me do on my webcam.
Who wants to watch me try to do one-legged squats in a pair of jeans that are way too damn tight?
You do? Well okay!
I like to do walking lunges to the bathroom, too.
What do you do in your office? We're talking exercise here people, not facebook.