Apparently God violated His own commandment when he gave instructions for construction of the Ark of the Covenant.
Or maybe your interpretation of Exodus 20:4 is defective.
Here’s a hint: Exodus 20:2-5 provides the complete context of Exodus 20:4.
"Apparently God violated His own commandment" [excerpt]