Any insight would be appreciated.
ויאמר ה' אל יהושע קום לך . . אתה גרמת להם והיינו דקאמר ליה בעי ועשית לעי ולמלכה כאשר עשית ליריחו ולמלכה וגו'
And Hashem said to Yehoshua, "Get up." . . Hashem said to him, You have brought [guilt] upon them. For that reason He said to him with reference to Ai: "And you shall do to Ai and its king, as you did to Jericho and its king; [only its spoil and its cattle you shall take as spoils to yourselves.]"
Rashi there explains that Yehoshua was somewhat guilty for what happened when Achan ben Carmi disobeyed his ban to take spoils from Yericho, since he was not commanded to consecrate the booty of the city and did it on his own account. For this reason by the next war against Ai, Hashem explicitly commanded them to take from the spoils.
Furthermore, the Midrash (Yalkut Shimoni 15:6) offers several reasons why Yehoshua declared the spoils of Yericho holy:
Since the invasion took place on Shabbos, the spoils were declared holy so that no one should derive benefit from the desecration of Shabbos (see also Rashi 6:17).
Just as one is required to separate a fraction of dough (challah) and declare this portion holy before he bakes, the first of the spoils in the conquest of Eretz Yisroel were declared holy.
Yericho was given the status of a city of idol worship from which no one is permitted to benefit (Devorim 13:17).
These reasons were specific to Yericho, and did not apply to the latter war against Ai.
The Malbim (8:2) and Abarbanel offer another explanation: Because Yericho was a supernatural war (circling the walls until they fell down) the booty was sanctified, whereas by Ai they were required to use natural war tactics ("set yourself ambush") and were permitted to partake of the spoils. (It is not advisable to benefit from the results of an open miracle - see Rashi to Ta'anis 24a "Ela Ke'echod").