Explanation:
It sounds like you're describing the formation of Earth's layers. The layers formed through a process called differentiation. Some time after the Earth formed, it got so hot that everything inside melted, the denser substances sank to the center, and the less dense substances rose to form layers. As the Earth cooled, most of the layers solidified.
A great deal of heat is still trapped inside the Earth, and it gets hotter as you go deeper. At 200km deep, the rocks are very hot. At the center of the Earth, the temperature is extremely high.