It never says that mountains stop earthquakes, but it stabilizes the earth from shaking. Nowhere does it say that it stops earthquakes. The arabic word for earthquake in the Qur'an is zalzalah but the words used in the verse is tameedah which means to shake, to sway, to swing. It is saying that lest it would shake WITH YOU. This means that if the mountains were not there then if you would have walked, then the earth would have moved with you. If you have swayed, the earth would have swayed with you. Normally, we know when we walk on the earth, the earth does not shake. So, Allah is saying he made the mountains to stabilize the earth. You are clearly making misconceptions.