Hello
David first sinned against God and the manifestation of him sinning against God was his adultery and murder. Nathan the prophet in telling David the story of the rich man stealing the poor man's lamb to feed his guest(s) tells us that David had turned the people also away from God and as such they committed the same sin as David with respect to God and had also turned away from God, however Nathan the Prophet did not fully understand the message that he had given King David from God. Nathan, thought that King David's adultery and causing Uriah to be killed was the understanding of the story that he had told and he went on to tell King David the consequences of his sin against God and his manifested sins against God's statutes.
As the story is related to us in the OT it would seem that the story relates to a relatively short timeframe, whereas if we read the Chronology of King David's sons, we would understand that they occurred over a much longer period of time and that the time period between when David committed his adultery with Bathsheba and the death of his first son with Bathsheba spans around 7 or so years. How do I know this? We are given this information in 1 Chron 3:1-9: -
1 Chronicles 3:1-9: - 3:1 Now these were the sons of David who were born to him in Hebron: The firstborn was Amnon, by Ahinoam the Jezreelitess; the second, Daniel, by Abigail the Carmelitess; 2 the third, Absalom the son of Maacah, the daughter of Talmai, king of Geshur; the fourth, Adonijah the son of Haggith; 3 the fifth, Shephatiah, by Abital; the sixth, Ithream, by his wife Eglah.
4 These six were born to him in Hebron. There he reigned seven years and six months, and in Jerusalem he reigned thirty-three years. 5 And these were born to him in Jerusalem: Shimea, Shobab, Nathan, and Solomon — four by Bathshua the daughter of Ammiel. 6 Also there were Ibhar, Elishama, Eliphelet, 7 Nogah, Nepheg, Japhia, 8 Elishama, Eliada, and Eliphelet — nine in all. 9 These were all the sons of David, besides the sons of the concubines, and Tamar their sister.
Now we know that Solomon was conceived when David went in to Bathsheba to console her after the death of Shimea, his first born with Bathsheba and the above chronology of King David's children tells us that Bathsheba had born two other children to David before Nathan the Prophet came and challenged David about his sin of turning away from God.
God gave King David around 7 to 8 years to repent of his sins, but when David was confronted by Nathan, David had forgotten about his sin of turning away from God and also causing the people to turn away from God as well.
David, took full responsibility for his sins and for causing the people to also turn away from God. King David's root sin was his turning away from God. That was the primary sin that God required David to repent of. The other manifested sins that were the fruit of David turning away from God, were also dealt with by God and the death of David's son, Shimea, when he was a young boy of around 6 or 7 years of ages, was God's punishment for David for his manifested sins.
When God begins to challenge us of our sin of turning away from God, we too do not always remember this sin but rather we only remember the openly committed manifested sins that came about because of our primary sin of turning away from God. The sin of turning away from God is the sin that is hidden in our hearts.
King David committed the same sin of turning away from God around three times and God came against David each time and poured out his wrath against King David each time that he had turned away from God, but God relented each time that David repented of his sin of turning away from God. The manifested sins resulting from the primary sin of turning away from God also had consequences for the nation and for King David.
King David had a heart after God's hearth and he, like God, took responsibility for all of the sins of the people plus his own. God takes responsibility for the sins of the people of the earth and has acted so that the sins of mankind can be hidden by the sacrifice that God put in place when his son also died on the cross for all of the sins of humanity.
We, as humanity, are very willing to repent of our obvious manifested sins, to God, but we find it difficult to repent of our being continually turned away from God because of Adam turning away from God.
We need to all come into a deeper understanding of what our relationship with God really is and stop putting band aids over our the festering cause of our manifested sins that we can see and relate to easily.
Shalom