At that time Joshua pronounced this solemn oath: “Cursed before the Lord is the one who undertakes to rebuild this city, Jericho: “At the cost of his firstborn son he will lay its foundations; at the cost of his youngest he will set up its gates” (emphasis added).

Joshua 6:26 (NIV)

Why did Joshua curse Jericho?

Because it and everything in it had been devoted to God, as seen below.

The city and all that is in it are to be devoted to the Lord. Only Rahab the prostitute and all who are with her in her house shall be spared, because she hid the spies we sent. But keep away from the devoted things, so that you will not bring about your own destruction by taking any of them. Otherwise you will make the camp of Israel liable to destruction and bring trouble on it. All the silver and gold and the articles of bronze and iron are sacred to the Lord and must go into his treasury” (emphasis added).

Joshua 6:17-19 (NIV)

Jericho was “devoted” to God. The word used for devoted is “cherem or hê·rem,” which means to be utterly destroyed as an offering to God. Therefore, because Jericho belonged to God, anyone who tried to take it “away” from God would be cursed. Look at what happened to Achan when he took some of the plunder for himself. Achan and his entire family were killed because they tried to steal from God. 

Why didn’t Joshua curse other cities in Canaan? 

Only the inhabitants of Canaan were devoted to destruction, while their cities, towns, and lands were given to the Israelites. I also see Jericho as a sort of “first fruits” in Canaan since it was the first city conquered in the Promised Land.