You can have weight loss with prescribed medication. The problem is it can become mentally addictive to the point every time you gain weight, you will feel the need for more medication. Long term effects of medication takes a toll on the liver, kidneys, heart and overall health.
The reason folks gain weight after dieting is because the term "Diet" means extreme sacrifice. Most people can't wait to get off the diet, and once they do, go back to an unhealthy lifestyle. Then they begin to gain the weight all back.
Exercise is an important component in Fat Loss when combined with healthy eating habits. It is simple math. If you burn (exercise) more calories than you consume (eat), you will lose weight!
Exercise and healthy eating not only reduces caloric intake but also helps burn calories, even during rest periods.