From what i know, A field (which is actually force itself presented in a two-step process) does no work only if the displacement produced by that force is in a direction perpendicular to force. i.e.,
W = |F||d|cosΘ
If Θ =90°, w=0
Here. the displacement created by the electromagnets is in the same direction as the direction of magnetic field...so work is done.
A magnetic field does no work on a moving charge. But It does work on a magnetic moment by exerting a torque and twisting the moment e.g. a compass needle aligning itself to the magnetic field. And it can also do work by producing a net translational force on a magnetic moment if the field in inhomogeneous over the moment e.g. two magnets attracting one another.
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.
When a permanent magnet attract an object it does work pulling the object towards itself just as the earths gravity pulls object to itself. the work goes into kinetic energy like a mass falling. The energy is returned when someone does work by pulling the object away from the magnet.