The two electrons in the $p^2$ shells must have at least one different quantum numbers. The available quantum numbers are $n$, $\ell$, $m_{\ell}$, $s$, and $m_s$ (the spin projection).
Because they are fermions, Pauli forces to differ in at least one quantum number.
$L=2$ term
This gives you a $D$ term. In order for the two $\ell = 1$ electrons to make a $L=2$ total angular momentum, they must be aligned. So $m_{\ell_1} = m_{\ell_2}$.
The only quantum number that can differ is the spin projection: $m_{s_1} = -m_{s_2}$.
Vectorially, this would give you a total spin of $\mathbf{s}_1 + \mathbf{s}_1 = \mathbf{0}$, corresponding to the total spin quantum number $S=0$.
Hence why you should only retain the $S=0$ terms: $^{1}D_{2}$.
$L=1$ term
This gives you the $P$ term.
This would require maths that you can find here but you can show that the orbintal angular momentum part of the state is a triplet and it is antisymmetric. Hence, you need the spin part to be symmetric, i.e. to be a spin triple and hence $S=1$.
Hence $^3P_{2}$.
$L=0$ term
This gives you the $S$ term. The reason is the same as for the $L=0$ term. Hence you need different spin orientations. So $S=0$ and $^{1}S_0$.
The actual proof is (I think) quite mathematical with Slater determinants, but the general rule of thumb is that:
For odd numbers for the total angular momentum $(L= 1,3,5, ...)$ the
spatial wavefunction is antisymmetric upon particle exchange.
You know that $S=0$ is always antisymmetric and $S=1$ always symmetric, so you could derive which $D, P, S$ also from that.