The most basic answer to this is that the Lord was favoring David and not Absalom. So in order to answer this question more deeply, we must ask, “Why did God favor David and not Absalom?”

1 Samuel 13:14 and Acts 13:22 tell us that David was a “man after God’s own heart.” Although the scriptures record many of his failures and indicate that he was a man of war, his incredible humility is an example to us all. How many of us can boast a complete turnaround whenever our faults are pointed out to us? And yet David, even though he was king and in a position to ignore or even destroy any who disagreed with him, was completely changed when his sins were revealed to him. One famous example of this is in 2 Sam 12:13 after Nathan rebuked him over taking Bathsheba and having her husband Uriah killed. 

In contrast, Absalom was a man of idolatry. His mother was Maacah, the daughter of the king of Geshur (2 Samuel 3:3), which was a city-kingdom that the Israelites were supposed to conquer after the exodus but didn’t (Joshua 13:11-13). When he was banished from the kingdom, he returned to his mother’s homeland, where he most certainly immersed himself in more idolatry. He then planned a coup against the Lord’s anointed. Is it any wonder that God’s hand was against him?

To be even more specific, when David sinned and took Bathsheba, one of his punishments was prophesied in 2 Samuel 12:10-12, “…This is what the Lord says: Out of your own household I am going to bring calamity upon you…” But then, after David repents, Nathan says in verse 13, “The Lord has taken away your sin, you are not going to die.” So this experience was given to David as a punishment for his sin, but because of the way he was quick to repent, David was not killed and the kingdom was not turned over to Absalom.

Furthermore, God had significant plans for David’s royal lineage, including Jesus, the seed of Abraham. Hence, God’s favor was with David, and not with the idolatrous Absalom who was attempting to destroy His plans.