Here is what Dr. Scott Hahn wrote on it:
How did Moses deliver them from the punishment they deserved? By invoking the merit of their ancestors. He told the Lord: “Remember Abraham, Isaac, and Israel, your servants, to whom you swore by yourself, and said to them, ‘I will multiply your descendants as the stars of heaven, and all this land that I have promised I will give to your descendants, and they shall inherit it for ever’” (Ex 32:13).
Moses did not try to plead the case of the current generation, except insofar as they were offspring of the great patriarchs. In this story, we can see the temporal remission of punishment. God is going to destroy the Israelites; but he doesn’t. We can see Moses’ intercession, based upon the treasury of merits, the merit of the Fathers.
When the ancient rabbis discussed this story, they found no other way to explain it. The treasury of merit enabled them to safeguard God’s mercy and his justice simultaneously. They applied the same principles to the stories of Noah, whose righteousness served to redeem future generations from the ravages of the flood, and David, whose goodness alone saved his son Solomon from the disaster he merited for himself. (Hahn, Scott, Signs of Life: 40 Catholic Customs and Their Biblical Roots, 192-193)*There are all kinds of Scriptural examples of person A benefitting from the faith of person B. Think of the centurian’s servant who is healed because of the faith of the centurian (Mt 8:5-13), or the paralytic who was healed and forgiven because of the faith of his friends (Mk 2:3-5). Or the Canaanite woman who interceded for her daughter, healed by Jesus through the faith of the mother (Mt 15:22-28).