This particular claim is of interest because it is usually forwarded by two different groups, each with a very different agenda. It, of course, finds inclusion in the litany of "Bible contradictions" cut-and-paste lists that unimaginative atheists or other "free"thinkers are wont to send about the internet. However, the claim to contradiction is here also made by Roman Catholics, for the purpose of justifying that religion's use of statuary and crucifixes as aids in worship.
The very simple answer to this "contradiction" is merely to point out that the critic apparently has not bothered to read Exodus 20:4 in context. Quite clearly, the very next verse (v.5) provides the stipulated purpose for the prohibition on graven images - which is that they are not to be bowed down to and worshipped. This commandment prohibits idols and other artefacts to which man might be tempted to ascribe the glory and place of God. This commandment does not prohibit the making of all statuary or other artistic representations of men, animals, etc. It merely forbids the use of visual images for worship or as aids in worship - to help one "imagine" God or through which the attention of worship might be directed. Worshippers of God are to know that His children walk by faith, and not by sight. It is demeaning to the worship of God to create an image and then use it as a visual representation of God or as a way of "reaching" God. Thus, all idols are forbidden, as would things like crucifices, statues of Mary or the saints, and even artistic pictures of Jesus (if the picture is being used as an aid in worship). Any graven image which is made to be bowed down to or is used to help one envision or pray to God is covered in this commandment. However, "graven images" in the more general sense of artistic adornment and whatnot are quite clearly not covered in the stipulating addendum of verse 5.
This is why the 2nd commandment is not then in contradiction with Exodus 25:18. The cherubim on the ark of the covenant were not produced for the purpose of serving as a worship aid to Israel. There was no intention for them to be bowed down to or used as a channel for envisioning or reaching God. Their purpose was didactic (to teach God's holiness as they symbolically guarded the mercy seat) and artistic. Indeed, other than on very exceptional occasions early in Israel's history (such as when the Ark was brought out to go before an army, etc.), the Ark was hidden from view in the Tabernacle, and then later in the Temple. In the Temple, only the High Priest could enter into the Holiest of Holies where the Ark was located, and then only once a year to make atonement for the nation. Hence, it would not have even been available most of the time to serve as a worship aid, even if the people had desired to use it for such.
Indeed, the Bible does record an instance where a graven artefact which had originally been produced for a non-worship purpose began to be revered and worshipped, and was thus destroyed as an idol. This would be the brazen serpent produced by Moses in Numbers 21:8-9. The Bible records in II Kings 18:4, the children of Israel had begun to burn incense to the brazen serpent (apparently preserved as a treasured national artifact), thus going beyond merely acknowledging its place in their history and into an act of outright worship of the image. Because of this, King Hezekiah broke the image into pieces during his campaign to rid Judah of idolatry. This shows, then, the dichotomy which exists Scripturally between mere artistic, graven works, and those works which are used as aids in worship or even as replacements for God in worship. The brazen serpent was perfectly fine until it began to be misused as an object of worship, and then it became an idol to be destroyed.