The key to every power in Yoga comes from Samyama. If you apply Samyama to other body, then you enter that body. When the mind has attained to that state when it identifies itself with the internal impression of the object, leaving the external, and when, by long practice, that is retained by the
mind, and the mind can get into that state in a moment, that is Samyama.
- त्रयम एकत्र संयम ॥ 3.4॥
trayam ekatra sanyamah
(These) three (when practised) in regard to one object
Commentary of Swami Vivekananda on this verse
When a man can direct his mind to any particular object and
fix it there, and then keep it there for a long time,
the object from the internal part, this is Samyama; or
Dharana, Dhyana, and Samadhi, one following the other,
and making one. The form of the thing has vanished, and only
its meaning remains in the mind.
It is by applying Samyama yogi gain knowledge and power. See the verses of Patanjali sutra which describe how knowledge and power are described from power of Samyama.
By making Samyama on word, meaning, and knowledge, which are ordinarily confused, comes the knowledge of all animal sounds.3.17
By perceiving the impressions (ie. applying Samyama on past impressions), knowledge of past life. 3.18
By making Samyama on the signs in another’s both knowledge of that mind comes. By making Samyama on the form of the body the power of perceiving forms being obstructed, thepower of manifestation in the eye being separated, the
Yogi’s body becomes unseen. 3.21
By making Samyama on friendship, etc., various strength comes. 3.24
By making Samyama on the strength of the elephant, etc., that strength comes to the Yogi. 3.25
By making Samyama on the sun, (comes) the knowledge of the world. 3.27
(By making Samyama) On the moon, (comes) the knowledge of the cluster of stars. 3.28
On the pole star (comes) the knowledge of the motions of the stars. 3.29
Hence it is by the power of Samyama everything is accomplished. For the process of entering other body here is a Patanjali sutra.
बन्धकारणशैथिल्यात प्रचारसंवेदनाच च चित्तस्य परशरिरावेश ॥3.39॥
bandhakarannashaithilyat pracharasanvedanach ch chittasya parashariraveshah
When the cause of bondage has become loosened, the Yogi, by his knowledge of manifestation through the organs, enters another’s body.
Here is commentary of Swami Vivekananda on this verse
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 Purusa 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, according to the Yogi. 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 will be able to work through other things.
Hence entering other body means gaining omnipotence of mind (by the practice of Samyama)
But in rare cases Yogi may enter a body also with Vijnamaya kosha , Anandamaya kosha and Soul (ie. total body transfer) also in the case of ghost possession. Then body behaves through total samskaras of manomaya koshas as manomaya kosha is the store house of samskaras. Intellect also behaves in similar way as it is just the reflection of soul.
[Remember the situation of a person who is possessed by ghost. It depends upon samskaras of manomaya kosha how his mind behaves. ie. If the samsakars of the person who is possessed are strong (godly), then ghost can't control him.]
There is no problem for the Soul in this condition because soul is the mere witness of event. Both soul witness the event. Soul is just like a bird in tree which just witnesses the tree.
Adi Shankaracharya on Vivekchudamani says:
Of the tree of Samsara ignorance is the seed, the identification with the body is its sprout, attachment its tender leaves, work its water, the body its trunk, the vital forces its branches, the organs its twigs, the sense-objects its flowers, various miseries due to diverse works are its fruits, and the individual soul is the bird on it. (Verse 145)
Lastly parakaya pravesh is an advanced yoga. One can't make a person understand how sugar tastes by just saying it. He must taste it to know. Such is the case here. One must experience to understand the truth.