Temperature shifts
Earth's temperature swings from extreme to extreme is quite moderate. That is, coldest is generally around -40C and warmest is around 40-45C.
The Moon has two weeks in blazing hot sunlight, much hotter (depending on your reflectance) but well over 100C, and two weeks of much much colder. Not quite absolute zero (-273C), but pretty cold to around -173C.
That is a 273 degree Celsius difference. Versus, worst case of 80C on Earth. Things expand and contract a lot more over 273 vs 80. So designing circuitry that can handle the extremes is tough. Most commercial circuit boards will crack due to thermal expansion alone. Welds/solder are very tough to maintain across these temperature variations.
Most rovers and other probes that have an RTG, use it for heat, as much as for power as, to keep them warm overnight.
Mars is not as bad since it actually has an atmosphere to moderate it a bit. The temperature swings are not as bad, but still pretty bad. From a high of 20C to -153C (173 degree vs 273 for the moon).
Clearly it can be done as the current rovers have shown, but it is tricky and hard. It requires hibernating and using battery power to keep the heat going for some of it.
Radiation
The moon, lacking an atmosphere does not have much to protect from solar radiation. Mars has a bit better having a thin atmosphere.
Distance
Stuff breaks. Nothing lasts forever. Grease needs to be replaced eventually. With no way to fix it, more redundancy is required. However, because launches are so expensive, you are limited by mass.
Dust
Both the moon and Mars have surprisingly fine dirt that seems to get into and onto everything. The Apollo astronauts had trouble getting it off the space suits after the moon walks. Mars also has a lot of dust, as the various rovers have shown.
This stuff destroys moving parts as it manages to get in there somehow.
If you use Solar arrays for power on Mars, it also covers the arrays reducing power, as the wind deposits it. The Opportunity/Spirit missions found that the wind both deposited, and occasionally cleaned off the dust.
Now you need a solar array cleaning mechanism to maintain power, and yet another mechanical component to break, far away from anyone to fix it.
Battery lifespan
Rechargeable batteries have finite lifespans before they stop holding charge, or before it degrades to a level too low to survive.
Bearings
Moving parts can be affected by the dust, but the bearings and some kind of grease will eventually wear out.
Funding
While not a technological limit per se, when funding runs out to run the program, even if the vehicle/orbiter/probe is still working, it may have its life cut short by program management.