The two-dimensional (2D) van der Waals ferromagnetic semiconductors, such as CrI$_3$ and Cr$_2$Ge$_2$Te$_6$, and the 2D ferromagnetic metals, such as Fe$_3$GeTe$_2$ and MnSe$_2$, have been obtained in recent experiments and attracted a lot of attentions. The superexchange interaction has been suggested to dominate the magnetic interactions in these 2D magnetic systems. In the usual theoretical studies, the expression of the 2D Heisenberg models were fixed by hand due to experiences. Here, we propose a method to determine the expression of the 2D Heisenberg models by counting the possible superexchange paths with the density functional theory (DFT) and Wannier function calculations. With this method, we obtain a 2D Heisenberg model with six different nearest-neighbor exchange coupling constants for the 2D ferromagnetic metal Cr$_3$Te$_6$, which is very different for the crystal structure of Cr atoms in Cr$_3$Te$_6$. The calculated Curie temperature Tc = 328 K is close to the Tc = 344 K of 2D Cr$_3$Te$_6$ reported in recent experiment. In addition, we predict two stable 2D ferromagnetic semiconductors Cr$_3$O$_6$ and Mn$_3$O$_6$ sharing the same crystal structure of Cr$_3$Te$_6$. The similar Heisenberg models are obtained for 2D Cr$_3$O$_6$ and Mn$_3$O$_6$, where the calculated Tc is 218 K and 208 K, respectively. Our method offers a general approach to determine the expression of Heisenberg models for these 2D magnetic semiconductors and metals, and builds up a solid basis for further studies.