Moving the spacecraft against the magnetic force provided the energy needed to launch it. The energy expended to move a magnet against a magnetic force is stored in the magnetic field as potential energy.
The energy to launch the spacecraft came from moving the spacecraft against the magnetic force. The energy used to move a magnet against a magnetic force is stored as potential energy in the magnetic field. This magnetic force can convert potential energy stored in the magnetic field to kinetic energy.