The story of the Previous life/birth of Prahalāda is recounted in the Padma Mahā-Purāṇa.
Prahalāda was a brāhmiṇa, in his previous incarnation, known by Somaśarman, the youngest son of a great brāhmiṇa - Śivaśarman, a part of whose story I discuss in this answer. Śivaśarman tested his four elder sons one by one, and they all succeded, and hence, eventually through their father's grace they attained Mokṣa, by merging in Viṣṇu (Padma Purāṇa 2.3.67b-71). Thereafter, Somaśarman was put to rigorous testing by his father, which went on for a century and ultimately became satisfied & happy with his son, and thus, Śivaśarman blessed his youngest son (Somaśarman), and by the power of his yoga ascended to Vaikuṇṭha in the company of his wife.
After this Somaśarman began practicing the most intense form of tapas. When the time for his death was near asuras approached him. Fear about asuras gripped him, who was in deep meditation, and as he breathed his last thinking about asuras he was born in his next life as Prahlāda, son of Hiraṇyakaśipu and got killed by Viṣṇu in the war between Devas and Asuras.
After his parents departed for the Viṣṇu's abode, Somaśarman engaged himself in penance.
Chapter 5, Bhūmi-khaṇḍa, Padma Purāṇa
ततस्तत्र तपस्तेपे सोमशर्मा महाद्युतिः ।
अश्मलोष्टसमं मेने कांचनंभूषणं पुनः ॥९॥
जिताहारः स धर्मात्मा निद्रया परिवर्जितः ।
स सर्वान्विषयांस्त्यक्त्वा एकांतमपि सेवते ॥१०॥
- & 10. Then that very lustrous Somaśarman practiced penance there. He
also looked upon gold and ornaments like a stone or a clod of clay.
The righteous one had controlled his diet, he had given up sleep.
Giving up all objects of senses he resorted to solitude.
योगासनसमारूढो निराशो निःपरिग्रहः ।
तस्य वेला सुसंप्राप्ता मृत्युकालस्य वै तदा ॥११॥
आगता दानवा विप्रं सोमशर्माणमंतिके ।१२.क।
- to 12a. He had taken to the posture suited to profound and abstract
meditation, was desireless, and had no possessions. Then the time of
his death arrived. Demons came to that brāhmaṇa, Somaśarman.
मृत्युकाले तु संप्राप्ते प्राणयात्रा प्रवर्तिनः ॥१२.ख॥
शालिग्रामे महाक्षेत्रे ऋषीणां मानवर्द्धने ।
केचिद्वदंति वै दैत्याः केचिद्वदंति दानवाः ॥१३॥
एवंविधो महाशब्दः कर्णरंध्रं गतस्तदा ।
तस्यैव विप्रवर्यस्य सुचिरात्सोमशर्मणः ॥१४॥
ज्ञानध्यानविलग्नस्य प्रविष्टं दैत्यजं भयम् ।
तेन ध्यानेन तस्यापि दैत्यभीत्यैव वै तदा ॥१५॥
सत्वरं चैव तत्प्राणा गतास्तस्य महात्मनः ।
दैत्यभयेन संयुक्तः स हि मृत्युवशं गतः ॥१६॥
- (b). to 16. When the time of death of him, who was living (like that) at
the great sacred place - Śāligrāma, adding to the honor of sages,
arrived, some demons and goblins who knew thus (i.e. knew that his
death was imminent), spoke. The great sound (of the words uttered by
them) entered the cavity of the ears of Somaśarman, the best brāhmaṇa.
Fear of the demons entered him, who had adhered to knowledge and
meditation. Due to that meditation and the fear of the demons, the
life of the noble one quickly departed. Being full of the fear of the
demons he died.
तस्माद्दैत्यगृहे जातो हिरण्यकशिपोः सुतः ।
देवासुरे महायुद्धे निहतश्चक्रपाणिना ॥१७॥
युद्ध्यमानेन तेनापि प्रह्लादेन महात्मना ।
सुदृष्टं वासुदेवत्वं विश्वरूपसमन्वितम् ॥१८॥
- & 18. Therefore, he was born in the house of the demon
(Hiraṇyakaśipu) as Hiraṇyakaśipu’s son. In the war between gods and
demons, he was killed by Viṣṇu. The noble Prahlāda, while fighting
well saw (the form of) Vāsudeva, endowed with the universal form.
योगाभ्यासेन पूर्वेण ज्ञानमासीन्महात्मनः ।
सस्मार पूर्वकं सर्वं चरितं शिवशर्मणः ॥१९॥
- Due to his former practice of abstract meditation, the noble one had the knowledge (of his former birth, so) he recollected all the
former life of Śivaśarman:
प्रागहं सोमशर्माख्यः प्रविष्टो दानवीं तनुम् ।
अस्मात्कायात्कदा पुण्यं केवलं धाम उत्तमम् ॥२०॥
प्रयास्यामि महापुण्यैर्ज्ञानाख्यैर्मोक्षदायकम् ।
समरे म्रियमाणेन प्रह्लादेन महात्मना ॥२१॥
एवं चिंता कृता पूर्वं श्रूयतां द्विजसत्तमाः ।
एवं तु च समाख्यातं सर्वसंदेहनाशनम् ॥२२॥
- to 22. “Formerly, I whose name was Somaśarman entered the body of a
demon. When shall I, due to my great religious merit, called
knowledge, reach, from (i.e. casting) this body, the absolute, pious,
excellent, abode granting salvation?” The noble Prahlāda, thought like
this when he died formerly; O best of brāhmaṇas, listen. I have thus
told you everything that removes (your) doubts.
English Translation by N.A. Deshpande
Therefore, we see that in his previous birth Prahalāda was a very pious brāhmiṇa. However, at the time of his death, since his mind pondered over, and got fixed at demonic voices due to fear, therefore, he ultimately incarnated as a daitya through an Āsuraic womb. This story also justifies the fact, that - “as a man thinketh in his heart, so he becomes that”. Even king Purañjana became a woman in his next birth since he kept thinking about his wife throughout his life, and at the moment of death too. His story may be read from ŚB 4.6