The key is on the verse above; It was by faith. Imagine you are getting whatever you asked for, now God become more like a vending machine. This kind of attitude isn't going to get us far when temptation comes. And God knows it all too well.
When they marched around the walls, it is as if they were being challenged by the walls. Their faith are being challenged: Is God really going to crumble the walls? It was a test of faith, patient and perseverance. And the walls finally crumble, and it was by faith.
A lot of times, we can't seem to reach our target. Let me assure you that God always wanted to help you achieve in life. It is just a matters of timing. God's timing can't never be wrong can He? Have patient, persevere through the end, and most importantly have faith. Because it was by faith that great things achieved.