Problem: The Bible teaches that we should tear down altars (Deut. 12:2-3), but here, Joshua builds an altar just like this.
Solution: It is wrong to build altars to false gods, but it was commanded to build altars to the true God. In Deuteronomy 27:5-6, Moses gives instructions for building an altar to God (see also Ex. 20:24-25; 1 Kings 18:30-32).
Then Joshua built an altar unto the Lord God of Israel in mount Ebal (Josh 8:30)