He did things that Yahweh considers to be evil, like the descendants of Ahab had done, because after Ahaziah’s father died, they became his advisors. And Ahaziah died as a result of heeding their bad advice.