The Mishna teaches that hills that are worshipped do not become forbidden to Jews, although what is on those hills may become forbidden. The passage that is the source for this prohibition appears in Sefer Devarim (7:25) where the Torah forbids the gold and silver that are on them, but the ground itself cannot become forbidden.
One exception mentioned by the Mishna is the Ashera tree, which, although it is part-and-parcel of the land, nevertheless has been fashioned, in a sense, by human activity, since it was planted.
The idea that a natural formation like a hill or a valley might be worshipped as a god is a concept that exists back to prehistoric times, when pagans actually worshipped such things and sacrificed to them. One very early example of this was the cult of Ba’al Ḥermon that worshipped Mount Ḥermon, and whose cultic activities lasted into Mishnaic times. Occasionally the cult would worship an idol or statue that was related to the geographic place, while in other cases the worship would be focused on the place itself, like Mount Carmel, which was worshipped with no associated idol.
According to Rashi, the reason that we distinguish between the hills and what is on the hills is because in their natural form the hills cannot possibly become avoda zara. What is on them, however, becomes forbidden because of the aforementioned passage in Sefer Devarim. Pagans who worship the hills, however, will still be punished because of their intention to perform avoda zara. Rabbeinu Tam offers an alternative approach, arguing that the hills will be considered avoda zara, which is why those people worshipping them will be punished for doing so. The rule taught by the Mishna is that although the hills are considered avoda zara, they do not become forbidden.