Actually the weight of the food does matter, but not in the way that you think.
Food is composed of a bunch of different types of chemicals. Most has a fair bit of water in it which we urinate or sweat out after a while. Then there are proteins (building blocks that the body uses to grow or repair itself), carbohydrates (sugars and starches that the body burns to provide energy), fats (same) and fibre (which is the part that the body can’t digest and passes through).
Really only three of those ingredient types – carbohydrates, fats and proteins – are stored by the body for future emergency use and contribute to weight gain. They all become body fat or muscle, and they all contribute to the calorie count of food.
But food that weighs a lot but has really low amounts of those three types, like say celery, has almost all of its weight locked into water and fibre. It actually takes energy to go through the process of digesting food, so a celery stick or two actually helps with weight loss by both filling you up so you don’t eat as much other stuff, and consuming energy to process through your body.