No. There is no contradiction between Ezekiel and Moses. Although the two passages may initially sound contradictory, a closer look reveals they are not. In fact, I suggest the two passages provide us with complementary truths.
Truth Number One
On the one hand, the Exodus passage follows on the heels of the most important of the Ten Commandments,
You shall have no other gods before Me.
God, being a jealous God, will brook no competition for our love. God rightly demands absolute fealty from his children, and any time we allow anything to come between us and him, we commit spiritual adultery, a theme which other prophets address in detail (e.g., Jeremiah, chapter 3).
Does the spiritual adultery of one generation automatically pass from one generation to the next, up to three or four generations? Yes and no. Yes, it does, if the individuals of the second, third, and fourth generations of the same family choose to reject God (NET translation) or hate God (ESV translation) by turning away from him.
No, it does not, however, if the children of a God-rejecting earthly father choose to make the LORD, their lord and determine to love him with heart, soul, mind, and strength (Deuteronomy 6:5). In other words, repentance is always an option for the children of families trapped in the sin of spiritual adultery, regardless of the form it may take.
Heart-felt repentance is something God expects from every person, regardless of the example set by parents, be it good or bad. That is why repentance can pave the way for God to display his "covenant faithfulness to a thousand generations" (Exodus 20:6), provided each generation chooses to love God and keep his commandments (ibid.).
Three or four generations versus a thousand generations. How gracious and merciful God is!
Truth Number Two
On the other hand, Ezekiel deals with a complementary truth; namely, that each person in each generation bears the burden for his (or her) own sin. Each of us is accountable to God individually. Ultimately, God does not judge families, but each individual within each family.
A preacher I know likes to iterate the saying, "God has no grandchildren," and I agree with him fully. Whether you are or are not a child of God through faith in him, God judges us individually. Whoever commits a sin will suffer for it, since the soul that sins shall die (i.e., experience either separation from God or broken fellowship with God).
By the same token, however, whoever commits an act of righteousness will be rewarded for it. The undergirding truth is that no one is forced to sin, just as no one is forced to perform righteous acts.
Whether we sin or whether we live righteously, future generations will neither be judged for our sin nor rewarded for our righteousness. Each individual within each generation has the freedom to decide whom to serve: either the one true God, or the god of self and self-autonomy. This is not to say that one who chooses God will never commit sin; it is to say that the tenor of one's life is largely determined by the choice one makes either to serve God or not to serve God.
The Truths, Together
In conclusion, while sin can have devastating consequences inter-generationally for several generations in a row, righteousness can also prove to be a blessing inter-generationally for a thousand generations. And while neither our sin nor our righteousness will add one iota to the ultimate guilt or innocence of our progeny when they stand before God, who is the Judge of all the earth (Genesis 18:25), God's covenant faithfulness will ultimately win out, so to speak, for the millions of individuals down through the millennia who like Joshua say with full assurance of faith, "We will serve the LORD" (Joshua 24:15b).