  We present a systematic study of the electronic and magnetic properties of
two-dimensional ordered alloys, consisting of two representative hosts
(MnPS$_3$ and NiPS$_3$) of transition metal phosphorus trichalcogenides doped
with $3d$ elements. For both hosts our DFT+U calculations are able to
qualitatively reproduce the ratios and signs of all experimentally observed
magnetic couplings. The relative strength of all antiferromagnetic exchange
couplings, both in MnPS$_3$ as well as in NiPS$_3$, can successfully be
explained using an effective direct exchange model: they reveal that the
third-neighbor exchange dominates in NiPS$_3$ due to the filling of the
$t_{2g}$ subshell, whereas for MnPS$_3$ the first neighbor exchange is
prevailed owing to the presence of the $t_{2g}$ magnetism. On the other hand,
the nearest neighbor ferromagnetic coupling in NiPS$_3$ can only be explained
using a more complex superexchange model and is (also) largely triggered by the
absence of the $t_{2g}$ magnetism. For the doped systems, the DFT+U
calculations revealed that magnetic impurities do not affect the magnetic
ordering observed in the pure phases and thus in general in these systems
ferromagnetism may not be easily induced by such a kind of elemental doping.
However, unlike for the hosts, the first and second (dopant-host) exchange
couplings are of similar order of magnitude. This leads to frustration in case
of antiferromagnetic coupling and may be one of the reasons of the observed
lower magnetic ordering temperature of the doped systems.
