Diet affects weight loss by controlling the number of calories consumed, which is fundamental in creating a calorie deficit. By choosing foods that are less calorie-dense and more nutritious, individuals can feel fuller for longer periods, making it easier to eat fewer calories. This approach directly impacts the body's energy balance, leading to weight loss.