He did evil because he had not set his heart on seeking the LORD (2 Chronicles 12:14).
Seeking God does not happen automatically or by chance. It is a deliberate effort you take. The absence of such an effort can allow a vacuum in your heart which makes it easy for you slip into evil.
There are several promises in the Bible that tell us that if you seek God earnestly he will be found by you (Jeremiah 29:13). He will not hide himself from a genuine seeker for long.
Then it is important that you seek him for who he is. And not for what he can do for you. He is holy. Seek his face, the Bible says (Psalm 27:8).
There is nothing wrong about asking God for your genuine needs. But do seek to spend time alone with God just meditating on his majesty and greatness.
Now what can hinder you from seeking God. Sin certainly can. But more dangerous is self righteousness. It is one’s constant effort to be right before God.
In such a state of mind you will never seek God because you are already satisfied with your spiritual achievements. But they are as filthy rags (Isaiah 64:6) before God.
Finally, seek God with all your strength. Especially if you have sinned and moved far away from him. The promise of God is that you will find him if you seek him with all your heart and soul even from a backslidden condition (Deuteronomy 4:29)!
Return to your God and seek him with all your heart!