The outer solar atmosphere, the corona, contains plasma at temperatures of more than a million K, more than 100 times hotter that solar surface. How this gas is heated is a fundamental question tightly interwoven with the structure of the magnetic field in the upper atmosphere. Conducting numerical experiments based on magnetohydrodynamics we account for both the evolving three-dimensional structure of the atmosphere and the complex interaction of magnetic field and plasma. Together this defines the formation and evolution of coronal loops, the basic building block prominently seen in X-rays and extreme ultraviolet (EUV) images. The structures seen as coronal loops in the EUV can evolve quite differently from the magnetic field. While the magnetic field continuously expands as new magnetic flux emerges through the solar surface, the plasma gets heated on successively emerging fieldlines creating an EUV loop that remains roughly at the same place. For each snapshot the EUV images outline the magnetic field, but in contrast to the traditional view, the temporal evolution of the magnetic field and the EUV loops can be different. Through this we show that the thermal and the magnetic evolution in the outer atmosphere of a cool star has to be treated together, and cannot be simply separated as done mostly so far.