It is actually quite simple. According to thermophysics, heat always moves from and area of high heat to an area of low heat. Space has no heat at all. It is extremely cold. So, the heat from the burning hot earth dissipated into space. It's just like a hot coal cooling down of you keep it in the freezer. Also, It is impossible for water vapour to condense into magma. Magma is made of rock. It is just melted rock. Water vapour can never ever become magma, because they are two completely different substances. Also, I think you are under a misconception. the tectonic plates were formed before the water vapour condesed. The earth is made of several layers. the outmost layer is the one with tectonic plates. However, the plates are very closely fitted together. when the earth was forming, there were deep hollows. These giant depressions, or pits, were filled up by the condensed water vapour and became the oceans