Answer
No, it must not necessarily be true $A=D$
Work Step by Step
Since $AP=PD$, and $P$ is a nonsingular matrix, then it is invertible.
Multiplying $P^{-1}$ with the equation $AP=PD$, we get
$(AP) P^{-1}=(PD)P^{-1}$, thus $A(P P^{-1})=AI=A=(PD)P^{-1}$
Therefore, $A=PDP^{-1}$
So, it is not true that $A=D$