What are we currently learning about this question from the probes that have been and are now studying these planets?

Mercury, the planet closet to the Sun has a magnetic field, as does the Earth, the third planet. But the second and fourth planets from the Sun Venus and Mars, have no magnetic field.

Mercury, Venus, the Earth and Mars are all “terrestrial” planets why do two of them have magnetic fields and two do not?

What are we currently learning about this question from the probes that have been and are now studying these planets?