If you are going to count calories, for whatever reason, then yes..the calories in vegetables do count.
A person CAN gain weight from vegetables, if they eat 3500 extra calories of them than they need to maintain.
all calories = energy
and too much energy = weight gain
However, that said, I don't think the calories in vegetables (not cooked in oil) or fresh fruits should concern you. It is very hard to overeat vegetables, they are so far from being energy-dense. They are the complete opposite of energy dense. The only exceptions to this are avocados, coconut, mangos, bananas..and starchy vegetables such as corn, potatoes, squash, peas, and beans. And still, it would be pretty hard to overeat even THOSE fruits/vegetables.
It's the stuff like nut butters, spreads, salad dressings, condiments, jam, dried fruit, nuts, trail mix, cheese, ice cream, cake, pie, chocolate, candy, crackers, chips, other snack foods, pasta, cereal, caloric liquids, sugar-y foods, sugar yogurt, etc...that need to be moderated.....because they are very easy to consume too many calories of, since they are so energy dense.
A small amount tends to have a lot of calories.
So it's easy to "overeat" energy dense foods (calorie wise), and yet not feel full (stomach wise)...so you eat more to get full...and that is when you end up with excess calories that end up turning to excess weight.