What are the roles of medication in substance abuse treatment?

I know that there are some substance addictions that have no medications to counter the effects of the drug. So why is it that there are some substance addictions that do need medication?