Changing gender without surgery
Our thoughts at the time of death determines our future birth. The man too attached to his wife so naturally think of it at the last moment, so that he will be reborn in a woman's body. Similarly, if a woman thinks her husband at the time of death, it naturally will live his next life in a man's body.
As stated in the Bhagavad-gita, we must never forget that the body of matter, gross and subtle, are just clothes; they represent the jacket and suit of the soul. Thus, being a man or a woman relates only body garment.
Srimad-Bhagavatam 3.31.41
The living thing that stuck in material activities will focus excessively on his material body. Until his last hour, his thoughts will focus on his body and the beings that are connected to it. Thus he remains fully absorbed in bodily concept of life, so that at the moment of death, he is reluctant to leave his body. sometimes we see that a person about to die remains in a coma for several days before leaving his mortal coil. It would, for example, the case of a living that would delight to occupy a body of Prime Minister or President, but, realizing that he is going to be reborn as a dog or a pig, refuses to abandon his body. Then he remained in a coma for several days before dying.
Srimad-Bhagavatam 4.29.77
Ghosts and suicides
The spirits are deprived of physical body because of their actions deeply guilty, such as suicide. The last resort of the men holding the phantom is indeed to seek refuge in suicide, whether material or spiritual. Suicide material results in the loss of the physical body while spiritual suicide causes loss of individuality to be.
Srimad-Bhagavatam 3.14.24
Those who lead a life of sin and hold fast to their families, their homes or their country will not get a material body. They remain in an ethereal body consisting of the mind, ego and intelligence, and it is these beings there called ghosts. Their