We see that God Himself, who commanded the people not to engrave any idol or form, ordered Moses in the incident of the enormous snakes to “Make a fiery serpent, and set it on a pole; and it shall be that everyone who is bitten, when he looks at it, shall live” (Num.21: 8). So Moses did this and he was not breaking the second commandment.
Moreover, the Lord Jesus Christ teaches us that this act was a pattern of His sacred cross. He says: “And as Moses lifted up the serpent in the wilderness, even so must the Son of Man be lifted up, that whoever believes in Him should not perish but have eternal life” (John.3: 14,15).