Magnetic anisotropy is crucially important for the stabilization of two-dimensional (2D) magnetism, which is rare in nature but highly desirable in spintronics and for advancing fundamental knowledge. Recent works on CrI$_3$ and CrGeTe$_3$ monolayers not only led to observations of the long-time-sought 2D ferromagnetism, but also revealed distinct magnetic anisotropy in the two systems, namely Ising behavior for CrI$_3$ versus Heisenberg behavior for CrGeTe$_3$. Such magnetic difference strongly contrasts with structural and electronic similarities of these two materials, and understanding it at a microscopic scale should be of large benefits. Here, first-principles calculations are performed and analyzed to develop a simple Hamiltonian, to investigate magnetic anisotropy of CrI$_3$ and CrGeTe$_3$ monolayers. The anisotropic exchange coupling in both systems is surprisingly determined to be of Kitaev-type. Moreover, the interplay between this Kitaev interaction and single ion anisotropy (SIA) is found to naturally explain the different magnetic behaviors of CrI$_3$ and CrGeTe$_3$. Finally, both the Kitaev interaction and SIA are further found to be induced by spin-orbit coupling of the heavy ligands (I of CrI$_3$ or Te of CrGeTe$_3$) rather than the commonly believed 3d magnetic Cr ions.