Even the wisest man in the Bible (aside from Jesus) could not understand his own heart well enough to avoid it deceiving him. King Solomon had 700 wives to whom he clung in love, and in his old age they turned his heart away to other gods (1 Kings 11:1-4).
In fact, he did not even need to be wise to know the folly of clinging to those whom God had put off-limits, in Exodus 34:12-16 there is warning enough for even a simple man to understand. In his wisdom perhaps Solomon created a fine sounding argument for himself justifying why it was okay for him to sin and not heed the warning from God. He did not seem to realize that his own heart was divided, yet this is so obvious. We so easily deceive ourselves once we stop paying attention to God’s word (Jeremiah 17:9).
The final state of Solomon’s heart is a frightening reminder of the dangerous game idolatry is, and that it can start from just liking something a lot and being reluctant to let God take away our beloved toy.