With the example of the electromagnet lifting the car, the work is actually done by whatever power source is driving electromagnet. Griffiths explains an analogous scenario in Introduction to Electrodynamics 3e with a current loop and a metal block. The key is in accounting for the movement of the car itself towards the electromagnet, which produces a force component acting against the moving electrons in the circuitry of the electromagnet (in one frame of reference), requiring the power source driving the electromagnet to do work.
The geometry will always work out no matter which reference frame you take as static (car or electromagnet). Relative velocities change how the force is applied. This approach also works with examples like two bar magnets attracting each other, but must be explained on the atomic level.