Not all the altars that the Old Testament Jewish people built were God's altars. They could build their altar to Him, but He didn't direct them to do it every time they built one.
In the Old Testament, God told them to destroy those altars and to build His altars. God told them to cut down the grove in which this altar stood, and to burn the trees where those altars were built. Then they were to use the heat from this burning to burn their sacrifice to Him.
The altars were used for different kinds of sacrifices ... burnt offerings, peace offerings, and incense offerings, to name a few..
God told the priests exactly how to build His altars and where to build them. Some were built in the temple, some just outside the temple, and some were to be built completely away from the temple area. The high priest was the administrator of the altars.
Reverend Robert W. & Mary C. Butler