first off, let's notice the graph touches the x-axis at -1 and 3, namely, those are the zeros/solutions/roots of the polynomial and therefore, the factors come from those points.
now, at -1, the graph doesn't cross the x-axis, instead it simply bounces off of it, that means the zero of x = -1, has an even multiplicity, could be 4 or 2 or 6, but let's go with 2.
at x = 3, the graph does cross the x-axis, meaning it has an odd multiplicity, could be 3 or 1, or 7 or 9, but let's use 1.
![\bf \begin{cases} x=-1\implies &x+1=0\\ x=3\implies &x-3=0 \end{cases}~\hspace{5em}\stackrel{\textit{even multiplicity}}{(x+1)^2}\qquad \stackrel{\textit{odd multiplicity}}{(x-3)^1}=\stackrel{y}{0} \\\\\\ (x^2+2x+1)(x-3)=y\implies x^3+2x^2+x-3x^2-6x-3=y \\\\[-0.35em] \rule{34em}{0.25pt}\\\\ ~\hfill x^3-x^2-5x-3=y~\hfill](https://img.qammunity.org/2019/formulas/mathematics/middle-school/m5l252l15gfg6udgkhdwdhkre1zwd7kj1y.png)