Two reasons: I believe different foods are handled by your body in more complex ways that aren't easily measured by total number of calories. For example, your body probably handles 100 calories of white sugar differently from 100 calories of meat. So this affects the calories out part.
Also, different foods affect how soon you feel full. So that affects the calories in part.
Not that diet science actually studies any of this well.