There are many reasons but the main one is that hopping saves a lot of energy for birds that usually hop from branch to branch without using their wings. Flying is very energy draining.
Ground dwelling birds tend to walk more as they are quite heavy in comparison. For them, hopping would be too difficult and unnecessary as their food is on the ground.
As with all evolutionary developments, there are always exceptions of course.