But Ez 18 isn't on its own. It follows, and must be understood in context of the law, which says:
[Exo 20:5 KJV] Thou shalt not bow down thyself to them, nor serve them: for I the LORD thy God [am] a jealous God, visiting the iniquity of the fathers upon the children unto the third and fourth...