How mechanical layering affects local stresses, unrests, and eruptions of volcanoes