Nature of spin-lattice coupling in two-dimensional CrI3 and CrGeTe3