<s>[INST] How is $x(2x+7)+3$ equal to $(2x+1)(x+3)$? For some reason, $x(2x+7)+3$ seems like it should be equal to $(2x+7)(x+3)$ instead of $(2x+1)(x+3)$. How does $(2x+1)$ factor out of here?
The original equation was $2x^2+7x+3$.
Proof of this: https://www.desmos.com/calculator/2xpcqznkio
Notice how $x(2x+7)+3$ and $(2x+1)(x+3)$ overlap, but $(2x+7)(x+3)$ does not!
 [/INST] $2x+7$ is a factor of the first term, clearly. But it's not a factor of the second term. And therefore it can't possibly be a factor of the whole expression.
One could argue for the $(2x+1)$ version like this:
$$
x(2x+7)+3 = x(2x+1+6) + 3\\
= x(2x+1) + 6x + 3\\
= x(2x+1) + 3(2x+1)\\
= (x+3)(2x+1)
$$
however, this doesn't say much about how one would find such a thing in the first place.
If you want to find the factoring on your own, without knowing the answer beforehand, you could look at the original quadratic equation, and then use that for any quadratic expression $ax^2 + bx + c$ we have
$$
ax^2 + bx + c = a(x-r_1)(x-r_2)
$$
where $r_1, r_2$ are the two roots of the equation $ax^2 + bx + c = 0$, which you find using the standard quadratic formula:
$$
r_1 = \frac{-b+\sqrt{b^2-4ac}}{2a},\quad r_2 = \frac{-b-\sqrt{b^2-4ac}}{2a}
$$
Or, you could complete the square, then use difference of squares (following basically the proof of the quadratic formula above) to get
$$
2x^2 + 7x + 3 = \frac{16x^2 + 56x + 24}8\\
= \frac{16x^2 + 56x + 49 - 49 + 24}{8}\\
= \frac{(4x + 7)^2 - 25}{8}\\
= \frac{(4x + 7+5)(4x+7-5)}{8}\\
= \frac{4x+12}{4}\cdot\frac{4x+2}{2}\\
= (x+3)(2x+1)
$$
</s>