Joab and Shimei were both violent men who had wronged King David at some point. David let them live, but before he died, he told his son Solomon to kill those men. David said he trusted Solomon to know how to deal with those people, because Solomon was a man of wisdom. But David also described Solomon as young and inexperienced.
After David died and Solomon became king, Solomon still wasn’t wise. He said he was only a little child. He didn’t know how to carry out his duties. He couldn’t even distinguish between right and wrong. That’s why he still had to ask God to give him wisdom.
And even after God supposedly made him the wisest man in the world, Solomon still wasn’t wise! He wanted to be wise, but wisdom was beyond him. So Solomon certainly wasn’t a wise man back when he first became king, unless God was so incompetent that he turned Solomon into a fool when he thought he was making him wise.