The king of Judah's refusal to heed wise counsel was not merely a failure of human judgment, but the unfolding of a deliberate divine plan. When Amaziah rejected the sound advice offered to him [ביאור שטיינזלץ], his stubbornness was actually a direct decree from God [מלבי"ם].
The primary approach among commentators is that God orchestrated this unyielding mindset with the clear purpose of delivering Amaziah and the people of Judah into the hands of their enemies, specifically the king of Israel. This tragic turn of events was the realization of a preexisting divine plan designed to bring about the king's downfall [רש"י].
This severe punishment fell upon the king and his nation as a direct consequence of their own actions. It served as exact retribution because they had actively sought out and worshipped the idols of Edom [מלבי"ם, ביאור שטיינזלץ].