Let $A$ and $B$ be symmetric real $n\times n$ matrices such that $A^k=B^k$, then $A=B$.
Is my proof correct?
Take $\lambda\in \mathbb R$, then $A(v)=\lambda v\implies A^k(v)=\lambda^kv$.
Since the sum of the dimensions of the eigenvalue spaces of $A$ is $n$, we can be exactly sure that $v$ is an eigenvector with eigenvalue $\lambda$ of $A^k$ if and only if $v$ is an eigenvector with eigenvalue $\lambda^{\frac{1}{k}}$ of $A$ (and $B$).
Therefore $A$ and $B$ have exactly the same eigenvalue spaces, so we can take a basis of eigenvectors such that $A$ and $B$ coincide for each vector of the basis.$_\boxminus$
As stated in the comments, your solution is correct and complete.