otherwise it loses functionality and goes straight to the scrapyard.
Throw away a whole robot because a limb joint is seizing up? What an astonishingly wasteful thing to do.
With a meatbag, of course, when a limb loses functionality it is basically written off, and the meatbag remains partially functional until death.
When a robot limb becomes non-functional, there are more options. Firstly, robots are manufactured, not grown. Spare parts are available for mass-produced models, and less common ones at the very least get schematics and CAD diagrams. Hard-to-find parts can be removed from their owner, given a highly accurate 3D imaging and material scan and a suitable replacement can be procured via some appropriate means, ranging from molecular holography to blacksmithing or even carpentry, depending on the local technological capabilities and the particular requirements of the part. Non-functional examples of the same model (or at least other devices which share some common sub-assemblies) can be broken down for useful parts.
But replacement isn't even necessarily indicated. A seized part can be removed and dismantled, cleaned and re-lubricated and finally re-installed. Documentation for appropriate lubricants and protective sealants will be readily available, probably even included in the robot's own firmware. Mechanical and chemical properties may also be documented so alternatives can be obtained in less civilized locales where field-expedient repairs take priority over following precise maintenance instructions according to the robots' warranty.
How does a robot keep itself clean using available tools?
That rather depends on the nature of the robot now, doesn't it?
Some robots might be built in such a way that they don't really have a notion of "dirty", and can operate indefinitely in hostile environments such as vacuum-exposed sharp ultrafine regolith or your meatbag digestive tracts. They may be subject to problems caused by violent mechanical trauma, but being assaulted or suffering damage from unexpected environments (like the inside of a collapsing building) is not really getting "dirty" and so is outside of the remit of this question.
All robots will have specific environmental tolerances, and with some it just might not be possible to keep them going for days in a vast gritty swamp after a volcanic eruption or something, any more than a naked human is suitable for a trek over high mountain pass above the snowline.
A robot intended for use in a generally hostile environment such as a planetary surface covered in abrasives and surrounded by an atmospheric of corrosive gasses such as oxygen and oceans of conductive liquids will be suitably sealed against the environment and will probably be cleanable by being sprayed down with water. Intrusions of water and grit and gas into the delicate interior can be dealt with by dismantling and cleaning and re-assembling as per the documentation, when a suitably clean environment is reached. If that seems unreasonable, then consider how partially dismantling humans for repair demands sterile conditions or they just up and die of infection, rather than just make nasty grinding noises and move at quarter speed for the next week.