Excellent question.
The problem is further confounded by the fact that in 2 Kings 10:30 Jehu is even rewarded for his action in Jezreel, so how can Jehu be both rewarded and punished for the same act?
Some commentaries suggest that though Elijah prophesied that this will happen to the house of Ahab, it still does not vindicate the perpetrator from his immoral actions,
and though this was done according to the will of God, and for which
he received the kingdom, and it was continued in his family to the
fourth generation; yet, inasmuch as this was not done by him from a
pure and hearty zeal for the Lord and his worship, and with a sincere
view to his glory, but in order to gain the kingdom, increase his
power, and satiate his tyranny and lust... It
may be observed, that God sometimes punishes the instruments he makes
use of in doing his work; they either over doing it, exercising too
much cruelty; and not doing it upon right principles, and with right
views, as the kings of Assyria and Babylon, Isaiah 10:5. (Gill's Exposition of the Entire Bible)
It should be added that this was also the case with Egypt. Though God has ordained already in the days of Abraham that the Israelites will be enslaved by them (Gen. 15:12), the Egyptians were nevertheless punished severely for their cruel acts.
However this still does not solve the problem with 2 Kings 10:30 where Jehu is clearly rewarded for his acts. For this reason, some came to regard these two accounts as irreconcilable,
The destruction of the house of Ahab is considered by the author of 2
Kings to be a righteous act. Yahweh even rewards Jehu with four
generations of kings to sit on the throne of Israel (2 Kings 10:30),
and Jehoahaz, Jehoash, Jereboam II, Zachariah all descendants of Jehu
ruled Israel for a total of 102 years (including the reign of Jehu).
The prophet Hosea though writes in Hosea 1:4–5 that the house of Jehu
was punished by God through the hands of the Assyrians for the
bloodshed carried out by Jehu at Jezreel. (Wikipedia - Jehu)
And in Cambridge bible,
Hosea (in whom natural peculiarities have been purified and not
extinguished by the spirit of prophecy) regards the conduct of Jehu in
a different light from the writer of 2 Kings 10:30. The latter praises
Jehu for having ‘done unto the house of Ahab according to all that was
in by mind’; he speaks on the assumption that Jehu had the interests
of Jehovah’s worship at heart, and that he destroyed the house of Ahab
as the only effectual means of advancing them. The former blames Jehu
apparently on the high moral ground that Jehovah ‘desires mercy (love)
and not sacrifice’ (Hosea 6:6). He speaks as the Israelites of his
time doubtless felt. They no more recognized Jehu as a champion of
Jehovah than did the priests of Baal whom he basely entrapped (2 Kings
10:18, &c.). But Hosea doubtless felt in addition that the idolatry to
which the house of Jehu was addicted rendered a permanent religious
reform hopeless. Image-worship could not be suppressed by such
halfhearted worshippers of Jehovah, and hence, Jehovah’s moral
government of His people must have made it certain to Hosea that even
on this ground alone the dynasty of Jehu could not escape an
overthrow.