How earthquakes and volcanoes are formed