I have the following for $\operatorname{tr}(D^2) = 0 \implies D = 0$
If $D = 0$, clearly $\operatorname{tr}(D^2) = 0$. If $D \ne 0$, it has entries on the diagonal, which, when squared, must be greater than $0$. Then the trace of the squared matrix must be greater than $0$ by definition of the trace, which is a contradiction to the premise that $\operatorname{tr}(D^2) = 0$, hence $D = 0$. Is this correct reasoning, and if so, is there a better way to show this than writing all this out?
Edit: Forgot to mention that D is a diagonal matrix
A counterexample is the identity matrix $D=I_2\in GL(2,\Bbb F_2)$, where $D^2=D$ has trace $2=0$, but $D\neq 0$. Over the complex numbers consider $$ D=\begin{pmatrix} 1 & 0 \cr 0 & i \end{pmatrix}. $$ Then the trace of $D^2$ is zero, but $D$ is nonzero. Over a field of arbitrary characteristic, consider $$ D=\begin{pmatrix} 1 & 1 \cr -1 & 1 \end{pmatrix}. $$
Is it possible that your question is meant to be the following popular question Prove that $\operatorname{trace}(A^TA) = 0\ \iff\ A = 0$. ?