If you make them electromagnets and drive turn just so as the car passes, now it's a linear motor and would work to accelerate the car (this is how some rollercoasters work), but still doesn't magick energy out of the ether: something has to generate that power.
There's no such thing as a free lunch, and there's certainly no such thing as a lunch you get paid to eat.
A series of electromagnets driven by A/C could possibly work, either as a linear motor (fixed magnet in the car, and the road pushes or along) or at a much higher frequency as a wireless charging thing (if you can get the power high enough without being dangerous).
But at that point there are probably cheaper options.
The soil, its dirt
Through work and toil
The harvest of light