Let's say that you eat n calories of junk food every day (maybe that's all you eat or a part of your diet). Replace those with n calories of healthy foods. Great - you've probably made a good change for your health long term. But you haven't made progress towards losing weight because your calories are the same.
Now say you eat exclusively chocolate when you are hungry, during the whole day. And let's compare that to a day where you eat exclusively vegetables when you are hungry.
Will you have eaten the same amount of calories both days?