I hear this thing many times. Also, have another question how Nachiketa reached to Yama Lok and met with the Yamaraj?
Why he had to visit Yamaloka is mentioned at the start of Kathopanishad itself. It was actually due to his father.
Quoting from this page:
Vahasrava, being desirous of heavenly rewards (at the Viswajit sacrifice), made a gift of all that he possessed. He had a son by the name of Nachiketas.
II. When the offerings were being distributed, faith (Shraddha) entered (the heart of)Nachiketas, who, though young, yet resected:
III. These cows have drunk water, eaten grass and given milk for the last time, and their senses have lost all vigour. He who gives these undoubtedly goes to joyless realms.
IV. He said to his father: Dear father, to whom wilt thou give me? He said it a second time, then a third time. The father replied: I shall give thee unto Death (or Yama).
V. Nachiketas thought: Among many (of my father's pupils) I stand first; among many (others) I stand in the middle (but never last). What will be accomplished for my father by my going this day to Yama?
VI. Look back to those who lived before and look to those who live now. Like grain the mortal decays and like grain again springs up (is reborn).
All things perish, Truth alone remains. Why then fear to sacrifice me also; Thus Nachiketas convinced his father that he should remain true to his word and send him to Yama, the Ruler of Death. Then Nachiketas went to the abode of Death, but Yama was absent and the boy waited without food or drink for three days. On Yama's return one of his household said to him.
Now, since Brahmin Nachiketa had to spend three complete nights without food in Yama's house (which is a serious offence for the house-owner i.e Yama), Yama, in order to compensate for his fault, urged Nachiketa to ask for three boons (one for each night).
This started the discussion between Yama and Nachiketa. The three boons (which were actually three questions from Nachiketa seeking ultimate knowledge) led to his enlightenment.
To show how he got enlightened i need to quote the whole Upanishad for you and which i am not doing :D
The last verse of the Upanishad says that Nachiketa obtained the Absolute as the result of Yama's teachings:
MrityproktAm nachiketohatha labdhA vidyAmetAm yogavidhim cha kritsnam |
BrahmaprApto virajohabhudvimrityuranyohapevyam yo vidadhyAtmameva ||
which means " Nachiketa, upon receiving this Brahmavidya propounded by Yama alongwith the Yogavidhis, obtained liberation. Anyone else, who also knows this VidyA, in a similar manner, obtains the same result (i.e liberation)."