Joshua doesn't know that, following the taking of the city of Jericho, his warriors have ignored God's instruction about destroying the "dedicated things," i.e. the items dedicated to other gods, like the Canaanite gods. They decided to keep them because ... well, you have your choice of reasons.
Targeting the next city, Ai, leads to a disastrous rout and Joshua (and the people) doubting the whole effort. God isn't listening to such garbage and tells them to clean out the other gods and demonstrate clearly that there is one God alone whom they obey. The greatest God isn't when God's people ignore clear instructions, and God isn't going forward with them if they can't get it right.
Jesus gets confronted in Matthew by the Zebedees who want the brothers on either side of the Lord in the Kingdom. (The next chapter has Jesus entering Jerusalem.) Jesus rebukes them, but the others hear about their hubris. We can imagine all 12 bickering like children over who gets which slice of cake that they haven't even been offered.
Time for a Kingdom lesson. Jesus once again tells them how the Kingdom turns everything upside down, a message that will get repeated in Matthew 25 in very memorable form. Continue this by watching the sermon video below, noting the downloads below the video panel.