>>36431241I'm not sure about the magma stone, but seeing as Heatran in Pokémon Generation is really dangerous and very destructive, maybe an ancient civilization invented that mechanism to keep them sealed.
I know it's pure headcanon, but if I remember correctly, the Regis were sealed in their respective caves for similar reasons, you can also find the Regis and Regigigas in Sinnoh, so it's not too far-fetched.