Electronics in transit to, and on the surface of Mars are constantly bombarded by radiation. Hardened electronics are designed to resist the effects of this radiation to some degree, extending the wear lifespan to several months or even a couple years.
Physical shielding, such as heavy metals or a Faraday Cage can block many types of radiation before it affects the electronics. Depending on the shield strength, the incoming radiation is reduced to a lower value.
Electronics can be designed to resist radiation, to a certain degree. The size of semiconductor structures, for example, has an effect. Fine structures are more prone to radiation damage than chunky structures.
Redundancy, sanity checks, and dead man switches can ensure reliability and notify operators of errors. The system is able to continue working even if parts are damaged. The faulty parts are automatically recognized and switched off.