There are at least three main reasons for this.
First, transportation into and among hilly areas is harder to accomplish than transportation into and among flat areas. In other words, it will be harder and more expensive to bring all the necessities of life into a hilly area than into a flat area. This was truer in times past when land transportation was by animal power, but that is still relevant because the sites of most cities were chosen in those times.
Second, it is harder and more expensive to build in hilly areas. Building on flat land is much easier than building on hills since buildings need flat areas on which to rest.
The third, and probably most important, reason is that agriculture is easier in the plains. It is hard to do large-scale agriculture on hills. Large-scale agriculture is necessary for feeding dense populations. In the past, when it was harder to transport food, this meant that cities had to be built in flat areas so that there could be enough farms in the surrounding area to feed the urban population.