The trick is this: An average first-world person is probably burning between 1500-2000 calories a day just to keep their body functioning as they go about their day, assuming they're not entirely sedentary. If they burn an average of an extra 750 a day from activity beyond that, they can then consume that much more food without it being stored as energy. If they're using that activity to build muscle, their body will be consuming more energy at rest in addition to that extra caloric consumption from exercise.
The thing about a 400 calorie serving of fries (or an 800 calorie burger) is that if you ate a healthy alternative you are likely still consuming several hundred calories in that meal. So if I stay at home and have a turkey(150 calories) and cheese(100 calories) sandwich(200 calories from bread, 50 from mayo, etc.), a small salad (with dressing: 150 calories) and a glass of skim milk (100 calories), I'm eating say, 750 calories. If I replace that meal with the fast food equivalent, I'm nearly doubling my caloric intake from that meal to a ridiculous 1400, but that 1400 really only comes to an extra 650 calories. Now that is like an extra meal, and certainly not recommended, but going back to our original numbers, if you eat that 1400 calorie dinner, but had a 400 calorie breakfast and a 500 calorie lunch then your intake for the day is 2300, most or all of which will be burned off by simply existing if you're a fairly large person.
In short: as long as you're balanced in your approach to your overall diet, eating things like a basket of fries a couple times a week alone really wont have that much impact on your overall caloric intake and, in turn, your weight.