The mistake here is that the total energy of the system does not change - generally, the total amount of energy in a system never changes unless the energy enters or leaves the system somehow (for example, if you see the Earth alone as a system, then energy from the sun enters the system and some energy is lost to space in the form of heat).