Some of what Solomon wrote was reporting from a perspective that he suffered from during his period of great reversionism.
That was the time of having 1000 wives, practicing paganism of his wives, and flaunting his wealth, etc.
That was his "vanity, vanity, all is vanity" phase of his life...