Why are there not effective pharmaceutical treatments to prevent weight gain?
The two main factors are: 


Hunger is more complex to treat than pain (more pathways, more potential targets), and I would argue against your suggestion that we are good at treating pain: despite the term "painkiller" we aren't great at blocking pain except for with local anesthetics that block all nervous activity (lidocaine for example). For systemic pain relief, there are lots of long-term efficacy issues with either opiates or NSAIDs, and that isn't even taking into account:
Side effects. Amphetamines are great for suppressing appetite. They also mess with the cardiovascular system, are habit-forming, and cause psychological issues. "Fen-phen" is a famous example of an anti-obesity drug that had major side effects leading to massive lawsuits. A more recent supplement, Ephedra, had many of the same problems and was banned by the US FDA for those reasons.


There are some drugs that are used to treat obesity, but many of these have come into regulatory issues with side effects and are only used in special cases like in diabetics or as an absolute last resort.