It seems that you know, at least vaguely, what to do but not why it works, so let's go through the reasoning. We are given a polynomial
$$f(n) = 2n^2 + 7n + 3,$$
and we are asked to find all integers $n$ such that $f(n)$ is equal to some prime $p$. Obviously, some trick is needed here: There are infinitely many candidate values of both $n$ and $p$, so we can't just check them all; we need to somehow eliminate infinitely many cases at once. This is where the factorization
$$f(n) = (2n + 1)(n+3)$$
comes into play. Notice that whichever integer $n$ we pick, this lets us express $f(n)$ as a product of two integers. This immediately tells us that $f(n)$ will not be prime in most cases, because there are only four ways of writing a prime $p$ as a product of two integers, those being
$$(\pm 1)\cdot(\pm p) \quad \text{and} \quad (\pm p)\cdot(\pm 1).$$
Thus, if $f(n) = p$, we must have either
$$2n+1 = \pm 1, \qquad n+3 = \pm p$$
or
$$2n+1 = \pm p, \qquad n+3 = \pm1.$$
Notice how in each of these four cases, we have an equation that does not depend on $p$. This is exactly what we want: Even though there are infinitely many primes $p$ that $f(n)$ could potentially be equal to, in every case one of the four equations
$$2n + 1 = 1, \quad 2n + 1 = -1, \quad n + 3 = 1, \quad n + 3 = -1$$
must hold for $f(n)$ to be equal to $p$. We have thus eliminated all values of $n$ except for the solutions to the four equations above, those being $0, -1, -2$ and $-4$ respectively. Well, those are just finitely many cases that we can check by hand:
$$f(0) = 3, \quad f(-1) = -2, \quad f(-2) = -3, \quad f(-4) = 7.$$
We conclude that the only integers $n$ for which $f(n)$ is prime are $0$ and $-4$ (and $-1$ and $-2$ if you allow negative primes).