All leaders are capable of fault. Your examples are not free from corruption and abuse of power. Though Solomon had long been faithful to the LORD, late in life he fell away.
Part of Solomon's diplomatic success had come through marriages with foreign royalty. In all, he had 1,000 wives, many of them foreign. The LORD had forbidden his people to marry foreigners,1 for fear their religious practices would corrupt the true worship of the LORD. And in fact, this is what happened to Solomon.
Out of love for his wives, Solomon built shrines to their idols. To please his wives, he personally participated in the worship of those idols. This was no small sin, nor a positive expression of religious freedom. Each of these idols was connected with detestable practices. For example, both of the idols Chemosh and Molech required human sacrifice of children or infants in their worship.
And so Solomon, previously pure and committed to the LORD, introduced much sin into Israel in the name of political success. And this apostasy came in spite of God's great blessing to Solomon — God had personally spoken to him on two occasions, and had given him great wisdom, wealth, and security.
For this apostasy, God told Solomon he had decided to remove him from being king. Yet out of respect for Solomon's father, faithful King David, he would not do this during Solomon's lifetime, nor would he remove him completely — Solomon's heir would retain a small portion of the kingdom. This was fulfilled when Solomon's son King Rehoboam foolishly lost most of the kingdom.
As for King David, ironically, at the end of his life David himself became the victim of others' political maneuvering. His own son, Solomon, used contrived orders from David to launch a coup against the presumed successor, Adonijah, and to get rid of the members of the old regime (Joab, Abiathar) who supported Adonijah. Bathsheba herself may have orchestrated the coup.
History has mandated and exclaims that absolute power does corrupt absolutely.

Linkback:
https://tubagbohol.mikeligalig.com/index.php?topic=15082.0