Not all weight loss is intentional. Not all weight loss is beneficial.
Commenting on someone’s weight loss (aside from reinforcing the false ideal that fat=bad and thin =good) might be complimenting someone with cancer, an eating disorder, depression, food insecurity, substance abuse, and a whole lot of other conditions.
Best thing to do? Don’t comment on anyone’s body.