We have all done it. Heck, I've done it. We do what we think is the right thing at the time to get the results we want. When it comes to fad dieting though, it almost always backfires.
Have you ever noticed that when you gain the weight back that the type of weight seems to be worse? You have more cellulite than before. You're not as toned as you were when you originally went on said diet. This original weight doesn't get you back into the same clothes?
Here's an article I found the other day to help one of my clients cope (hopefully) with gaining weight in order to lose weight during my program: https://www.womenshealthmag.com/uk/food/weight-loss/a708795/body-weight-set-point/
She's currently in week 2 of the 12 week program and gained just under 3 pounds at her 2nd weigh in. Fortunately for me, she's allowing me to do my job but I've had clients swear to me that I'm "making them fat on purpose" only to have that turn out to be a completely different story after our work together.
Your body is programmed to survive. Deprive it long enough of the calories it needs to survive and it will adjust your metabolism so that you don't burn through your reserves. Do THAT long enough and your result is weight gain.
If you want to lose weight, fad diets out there tell us a caloric deficit will do it, but if you're already not eating enough, how does eating even less make sense?