This/these (kind of examples) is/are some of the exact reasons I believe God in and of the OT did change, or go through some changes over time, etc, leading up to Jesus time, etc, and also maybe after or during Jesus time, etc...
Cause there seems to be some change here, etc...
There is passage in Exodus as well (can't find it right now) that also talks about Him punishing the children for their fathers or forefathers crimes as well, etc, toward those who hate Him, etc, but shouldn't He have "already known", etc...? "Already known" who those ones would be, or would become, or who they already are or were or would be, etc, etc, etc, in the future, etc...? Shouldn't He have "already known", etc...?
Anyway...
Anyway, and that seems to have changed by the time we get to Ezekiel, etc, multiple places in that book that He says He is no longer going to do that, etc, or operate like that, etc, but that each one would only now only stand only each one individually for their own crimes only now, etc, almost as if, He (God in and of the OT), had "learned" that "that" wasn't very productive anymore, etc, but was actually counter-productive to what He was actually trying to do, or make happen, or cause to come to pass, and/or accomplish, etc...
And in my opinion, there seems to a lot of this in the OT, etc, as if God was "learning", etc...
Or growing, changing, and/or evolving, etc...
Why I think He is/always was/has to be/have been, etc, etc, etc, God the Spirit, etc, or God the Holy Spirit, etc...
Anyway,
God Bless!