Hydraulic brakes are always designed to retract the pistons. It is fairly obvious that as the MC is released, the hydraulic pressure drops below ambient and atmospheric pressure will push the pistons back, at least until the compensation port in the MC opens (in an open system). This provides for gross piston movements and provides the self-adjusting characteristic. It of course doesn't work perfectly if there is any air in the hydraulic system, since there is more MC movement required to generate the low pressure and the lowest pressure won't be as low this way.
What is less obvious is that the seals in the caliper body are designed to deflect and/or rotate slightly, and (provided the seals are in good condition, and the pistons are not binding, almost regardless of what is happening in the rest of the hydraulic system ) this always gives a small measure of piston retraction. In a well designed system, the piston retraction so obtained is enough to allow the pads to clear a disc that is in spec for runout. Note that the pads may be 'knocked back' (if there is no spring, eg on a motorcycle brake) but the pistons are not knocked back in the same way; they are retracted. If the pistons don't self-retract properly and are causing the high spots on the disc to contact the pads, this soon causes runout induced DTV (Disc thickness variation) in most vehicle brakes and this turns the brakes to junk. It is not an acceptable condition.
The seal design that provides retraction is most commonly (and is this way in all shimano calipers that I have stripped down) a square section seal that is in a groove that is not quite square; on the air side of the seal the groove has an angled face, so that the seal can deform and the piston can move slightly without sliding through the seal. Hydraulic pressure on the back of the seal deforms it into a parallelogram shape when the brake is on. When the seal recovers its square shape, the piston is retracted.
If the pistons don't retract 'enough' this can be because
- the disc isn't within spec for runout
- the hub bearings are slack
- the seal groove is filled with crud (typically corrosion product) on the air side
- the pistons are not free-running in the caliper bores
- the seal is contaminated and swollen so that it can't move in the same way as normal.
Both the last two are very common; all kinds of 'normal stuff' that you might use on your bike can result in the pistons (which are usually plastic) and/or the seals (which vary depending on who made them and what fluid is meant to be inside the hydraulics) swelling up.
The caliper bodies are usually machined after being surface finished on the outside, which means that the caliper bores are usually unprotected aluminium. If the bike sees weather, the bores usually start to corrode. This corrosion is x10 or x100 faster if there is road salt present. The corrosion is worst in the air side of the seal groove, and can completely prevent the usual seal rotation and therefore piston/pad self-retraction. Given a little more time, such calipers will fail to a leak at the piston seal, and the corrosion is no longer confined to the air side of the seal alone, and creeps under the seal itself.
If you are sure that no contaminants that might cause swelling have been near the pistons and seals, you can take it as read that non-retracting pistons is a good sign than the caliper may fail to a leak anytime soon because the piston bores/seal grooves are corroding. If you are adventurous you can strip and fix the caliper (the corrosion damage doesn't always damage the caliper beyond repair) but most folk just replace it with a new one.
BTW with Hope brakes (which use DOT fluid inside) they recommend that you use a silicone spray lubricant to help prevent water ingress into the piston bores. It is not clear to me that this product is 100% safe to use on mineral oil brakes; there is a chance that the solvent in it attacks the seals in mineral oil brakes, and may cause swelling.