It was explained in the first movie that this one guy named John taught voodoo magic to Charles Lee Ray and his associate, specifically on how to transfer their souls into other bodies if they ever were in danger of dying/going to jail. Chucky later goes to his house and murders him with a voodoo doll when John wants nothing to do with him anymore.
__________________ "Happiness is a lie. Life is horror. The light is always dying all across the universe. The last star will flicker out someday, when it does, all that remains is shadow. And I will be its king!"'-Amahl Farouk