To find $A$ given that $2I + A +A^2 = B$ where $B$ is given. How to find a matrix $A$ such that the following holds:
$$2I + A +A^2 = B,$$ where the matrix $B$ is given. I tried with char poly of $B$ but not getting any idea.
Note that it is also given that $B$ is invertible.
P.S. $B = \begin{pmatrix}-2&-7&-4\\ \:12&22&12\\ \:-12&-20&-10\end{pmatrix}$.

According to the other posts, we may assume that $B=\begin{pmatrix}4&1&0\\0&4&0\\0&0&2\end{pmatrix}$. Note that $B$ is cyclic and that $AB=BA$; thus $A$ is a polynomial in $B$: $A=aI_3+bB+cB^2$.
Then $A$ is in the form -considered by copper.hat-
$A=\begin{pmatrix}u&p&0\\0&u&0\\0&0&v\end{pmatrix}$, where $2+u+u^2=4,2+v+v^2=2$. The sequel is easy; we obtain $4$ solutions

EDIT. We can also use the Mostafa's trick. 
Since $B-7/4I_3$ is cyclic invertible, it admits $2^k=4$ square roots (where $k$ is the number of its distinct eigenvalues). In the same way as above, $\sqrt{B-7/4I_3}$ is in the form 
$C=\begin{pmatrix}u&p&0\\0&u&0\\0&0&v\end{pmatrix}$, where $u^2=4-7/4,v^2=2-7/4$.
