
It is a survival mechanism.
First and foremost, it prevents new lives being born into difficult circumstances, like a drought or a lack of food.
Mainly it protects the mother - who, if she hasn't got to compromise her own health by bringing up babies in less than perfect circumstances, she can hold off til things get better. It is a huge investment on her part to raise babies and it always carries the risk that she may not live long enough to get them on their road to maturity if food sources are scant or if there is an unusually high threat from predators.
Almost all small animals have the ability to reabsorb - when I say small, I am talking about those who have large litters born relatively helpless. The reason the litters are so large is because they need to have that many to ensure even one gets to maturity to carry on the line.
Times vary, but there is one cutoff - when the growing foetus/es starts to develop a skeletal system. Once this has happened, reabsorption is not possible. Rats and mice can reabsorb up to birth since their tiny, naked, foetus-like babies actually don't have a hardened skeleton just cartilage that develops post-natally.
Puppies are born with full skeletons so the cut-off point for reabsorption happens earlier in the pregnancy. There is a definite time after which it's not possible. I know in rabbits (gestation period 31 days) they can only re-absorb until the 19th-21st day. There's a cut off date for cats (gestation 9 wks like dogs) and I did once know when it was but off-hand I can't remember! If the pregnancy can no longer be continued after the time for reabsoption is past, then a miscarriage/abortion follows because the foetuses cannot be reassimilated once the skeleton has started to develop.
As to causes, sometimes comditions in the uterus mean that a litter is reabsorbed... or through infection or incompatibility.... the reasons are as varied and as unfathomable as in human pregnancies that never get properly started.
BTW: Brainless: often the extras - as in too many in the womb - just don't develop and get absorbed early on especially with overcrowding, while the others that are well implanted get on with it. I don't know if this is ever seen in dogs - and it is extremely rare in cats - but sometimes a cat will deliver a tiny mummified foetus when giving birth - it is one that failed to develop but was preserved in the body fluids nonetheless. I had this in one of my cats once.... it was atonishing! if a little gruesome.