It wouldn't because their molecular structure is different.
As I understand it, the idea is to make the immune system create antibodies against morphine (just an example), so as soon as you consume the drug the body detects it and the immune system would quickly respond and innactivate drug via different mechanisms. This is how vaccines work, kind of.
It's actually an interesting idea, I'm just not convinced that it would solve the bigger problem of addictive behavior. And it could lead to some kind of dystopian future, though not necessarily.