Solution (source code)

= Solution

Choose \b[$A=I_2$ and $B=3I_2$]. Then $AB=3I_2=A^2+A+I_2$. Both are real $2\times2$ <matrices>, as required.