In this example we are multiplying two binomials so FOIL method can be used.
$$ \begin{aligned} \left( \color{blue}{ x+2}\right) \cdot \left( \color{orangered}{ x^2+1}\right) &= \underbrace{ \color{blue}{x} \cdot \color{orangered}{x^2} }_{\text{FIRST}} + \underbrace{ \color{blue}{x} \cdot \color{orangered}{1} }_{\text{OUTER}} + \underbrace{ \color{blue}{2} \cdot \color{orangered}{x^2} }_{\text{INNER}} + \underbrace{ \color{blue}{2} \cdot \color{orangered}{1} }_{\text{LAST}} = \\ &= x^3 + x + 2x^2 + 2 = \\ &= x^3 + x + 2x^2 + 2 = \\ &= x^3+2x^2+x+2; \end{aligned} $$