Mahārāja Bharata, despite a life of severe penances, thought of a stag at the time of his death and thus became a stag after death. However, he did retain a clear consciousness of his past life and realized his mistake. It is important to realize that one's thoughts at the time of death are influenced by the actual deeds which one performs during his life.
In the Śrīmad-Bhāgavatam (Third Canto, Chapter Thirty-two), the process of entering the moon is described as follows:
Materialistic-minded men, who have no information of the kingdom of God, are always mad after material acquisition of wealth, fame and adoration. Such men are interested in the progressive weal of their particular family unit for their own self-satisfaction and so are also interested in the progress of social and national welfare. These men attain their desired objects by material activities. They are mechanically engaged in the ritualistic discharge of prescribed duties and are consequently inclined to satisfy the Pitās, or bygone forefathers, and controlling demigods by performance of sacrifices as prescribed by the revealed scriptures. Addicted to such acts of sacrifices and ceremonial observances, such souls enter into the moon after death. When one is thus promoted to the moon, he receives the capacity to enjoy the drinking of soma-rasa, a celestial beverage. The moon is a place where the demigod Candra is the predominating deity. The atmosphere and amenities of life there are far more comfortable and advantageous than those here on earth. After reaching the moon, if a soul does not utilize the opportunity for promotion to better planets, he is degraded and forced to return to earth or a similar planet. However, materialistic persons, although they may attain to the topmost planetary system, are certainly annihilated at the time of the cosmic manifestation's dissolution.