Let $$ B = \begin{bmatrix} a & 1 & & & \\ & \ddots & \ddots & \\ & & \ddots & 1 \\ & & & a \end{bmatrix} \qquad\text{and}\qquad A = \begin{bmatrix} a & & & \\ 1 & \ddots & & \\ & \ddots & \ddots & \\ & & 1 & a \end{bmatrix}. $$ I need to prove they are similar. I was thinking using the characteristic polynomial which is as definition $p(A) = t^n - t(\operatorname{tr}A) + \det A$ and $p(B) = t^n - t(\operatorname{tr}A) + \det B$ and then both have the same trace and same determinant so their characteristic polynomial is the same so they are similar to the same matrix and hence similar to each other?
Yet I came across another solution suggesting $A ,B$ are both same transformation matrices for different bases of $\mathbb R^n$. So I’m not sure if my solution is ok.
Your approach is wrong. For instance, the matrices $\left(\begin{smallmatrix}0&1\\0&0\end{smallmatrix}\right)$ and $\left(\begin{smallmatrix}0&0\\0&0\end{smallmatrix}\right)$ have the same characteristic polynomials ($\lambda^2$). However, they are not similar.
Of course, you can always use the fact that every matrix is similar to its transpose. But, in this case, the approach that you suggest at the end of your question (same transformation, different bases) is perhaps the best one.