At Jerico, the Hebrews were concerned with infection -- cross-contamination -- racial, cultural and spiritual. They eliminated it the best way they knew how.
Not an uncommon thing. Genetic defense is instinctive throughout the animal kingdom and carried to the extreme by H.Saps. It is most likely this instinct that resulted in Homo neanderthalensis being elimated by H.sapiens.
Witness the genocide committed BY the Hebrews at Jerico. Then, thousands of years later, witness the genocide committed AGAINST the Hebrews at Auschwitz. Witness the eugenic behavior by America during the early 20th century.
Right? Wrong? Zoologically, right and wrong is judged by what best ensures the robust continuity and integrity of the species, tribe, pack, and individual. Humans tend to apply this same critieria socially and culturally (including with their religions). Every generation of humans will have to determine the "right" and "wrong" based upon the zeitgeist they find themselves in.
During Joshua's time, it is possible that genocide was not considered the atrocity it is today. Tomorrow, who knows?
In the mean time, which generation is it that will be qualified to pronounce judgement upon the actions of the Creator -- if indeed such deeds as Jerico were His doing?