Let $A$ be an $n \times n$ nonsingular matrix having distinct eigenvalues and $B$ is a matrix satisfying $AB = BA^{-1}$

Let $$A$$ be an $$n \times n$$ non singular matrix having distinct eigenvalues. If $$B$$ is a matrix satisfying $$AB = BA^{-1}$$ , show that $$B^{2}$$ is diagonalizable.

I need to show that $$B^{2}$$ is diagonalizable. If I prove that $$AB^{2} = B^{2}A$$ then, it implies that $$B^{2}$$ is diagonalizable, since it commutes with a diagonal matrix.

But I don't how to prove that $$B^{2}$$ commute with $$A$$. Any hint would be helpful.

Note that\begin{align}AB^2&=(AB)\left(BA^{-1}\right)A\\&=\left(BA^{-1}\right)(AB)A\\&=B\operatorname{Id}BA\\&=B^2A.\end{align}