Yoga Sutras 3.39
Patanjali, explained by Swami Vivekananda
बन्धकारणशैथिल्यात् प्रचारसंवेदनाच्च चित्तस्य परशरीरावेशः ॥
bandhakāraṇaśaithilyāt pracārasaṃvedanācca cittasya paraśarīrāveśaḥ
When the cause of bondage of the Chitta has become loosened, the Yogi, by his knowledge of its channels of activity (the nerves), enters another's body.
In plain words: When the mind's ties to the body loosen, a yogi who understands the mind's pathways through the nerves can enter another person's body.
Swami Vivekananda explains
The Yogi can enter a dead body and make it get up and move, even while he himself is working in another body. Or he can enter a living body and hold that man's mind and organs in check, and for the time being act through the body of that man. That is done by the Yogi coming to this discrimination of Purusha and nature. If he wants to enter another's body, he makes a Samyama on that body and enters it, because, not only is his soul omnipresent, but his mind also, as the Yogi teaches. It is one bit of the universal mind. Now, however, it can only work through the nerve currents in this body, but when the Yogi has loosened himself from these nerve currents, he can work through other things.