I want to write an answer about the logic of the proof. This is a common source of confusion because the proof is often presented as a proof by contradiction, although it can be written as a direct proof using the same ideas.
I will present two proofs of the result, one by contradiction and one by direct reasoning. For the first part of this answer, I will use the ordinary, informal, mathematical understanding of "proof by contradiction" and "direct proof". In the last section, I will comment further on that understanding among logicians.
I will also assume we already know that every natural number larger than 1 has some prime factor.
Here is one telling of Euclid's proof by contradiction, which can be seen in other answers here:
Proof 1 Working by contradiction, assume the result is false. Then there are only finitely many prime numbers. Write them as $p_1, p_2, \ldots, p_n$ and form the number $q = p_1p_2\cdots p_n +1$. Then $q > 1$, and so $q$ is divisible by a prime. But the remainder of dividing $q$ by $p_i$, for any $i\leq n$, is 1. So $q$ has no prime factors, which is a contradiction.
To write a direct proof, in the sense of ordinary mathematics, we need to clarify what it means to prove directly that a set is infinite. Although the naive definition of "infinite" is "not finite", the way to create the direct proof in ordinary mathematics is to move to a different characterization of "infinite" which is phrased in "positive" rather than "negative" terms. One such characterization says that there are infinitely many primes if and only if there is an unending sequence $p_1, p_2, \ldots$ of distinct primes. We don't care whether the sequence includes all primes, it just has to contain some of them, but it can't repeat or end.
Using that characterization of infinite sets, we can recast the proof above as a direct proof:
Proof 2 We inductively construct a sequence $p_1, p_2, \ldots$ of distinct primes. To start, let $p_1 = 2$. Now, for the "inductive step", assume we have constructed distinct primes $p_1, \ldots, p_n$. Form the number $q=p_1p_2\cdots p_n+1$. This number $q$ is greater than 1, so it must be divisible by some prime $p$. But the remainder of dividing $q$ by $p_i$ for any $i\leq n$ is 1, so $p$ cannot equal $p_i$ for any $i \leq n$. Thus we can take $p_{n+1} = p$. Continuing in this way, we can construct an infinite sequence $p_1, p_2, \ldots$ of distinct primes. In particular, this shows that there are infinitely many primes.
Advantages of the direct proof
There are several advantages of the direct proof (proof 2) over the proof by contradiction (proof 1).
First, the direct proof gives an algorithm that can be used to enumerate a sequence of primes. Not every direct proof gives an algorithm, but many do.
So the direct proof here gives us more than the statement of the theorem requires. This is often the case with direct proofs and is one reason to favor them.
Second, because the direct proof never makes any false assumptions, every statement in the direct proof is true. This is not the case for the proof by contradiction, as Michael Hardy has mentioned in a separate answer. In a proof by contradiction, some statements may be proved using the false assumption that starts the proof. So if we pull a statement haphazardly from the middle of the proof, we have no way to tell whether it is true or not without further analysis.
This leads to a common confusion about Euclid's proof, which underlies the original question here. The confused idea is that if $p_1, \ldots, p_n$ are primes then $p_1p_2\cdots p_n + 1$ is also prime. As the question statement shows, that is false. But it can be deduced from the statements in the proof, in some way, by haphazardly pulling statements from the middle of the proof by contradiction and then proceeding as if those statements were true. Some ways of writing the proof by contradiction suggest this misinterpretation more strongly than mine.
As soon as you make the false assumption in a proof by contradiction, everything else in the proof is overshadowed by that assumption, in the sense that you cannot rely on any later statement of the theorem being true unless you can prove that statement separately. This is another practical reason to prefer direct proofs.
An aside on formal logic
So far I have been using the informal, "naive" understanding of direct proof and proof by contradiction. This is how mathematicians use these terms outside of formal mathematical logic. For most mathematical purposes, you want to use this informal terminology, because that is how other mathematicians will interpret it.
In mathematical logic, where mathematical reasoning itself is our area of study, we have a more formal understanding of "proof by contradiction". This is particularly important in constructive mathematics (also called intuitionistic mathematics in common usage) where they have to be particularly careful about negation and proof by contradiction.
In that setting, the proof "by contradiction" above is actually viewed as a direct proof that "the set of primes is not finite", assuming appropriate axioms including "every number greater than 1 is divisible by a prime". This is because a statement of the form "not $P$" is taken to be an abbreviation for "$P$ implies $\bot$", where $\bot$ is an identically false proposition like $0=1$. Proof 1 above can be turned into such a proof as follows.
Proof 3 We want to prove that the set of primes is not finite. So we assume that there are only finitely many prime numbers. Write them as $p_1, p_2, \ldots, p_n$ and form the number $q = p_1p_2\cdots p_n +1$. Then $q > 1$, and so $q$ is divisible by some prime, which must be in the original list. Call that prime $p_j$. Then the remainder of dividing $q$ by $p_j$ is $0$. But we can compute the remainder of dividing $q$ by $p_j$ to be 1 as well. Thus $0=1$. This proves that the set of primes is not finite.
What makes this a "direct" proof in the formal sense? It can be proved (with appropriate axioms of number theory) in minimal logic, which is a reasoning system that does not have the inference rule for proof by contradiction.
In constructive mathematics, they often redefine concepts that have "negative" definitions in ordinary mathematics. In particular, they would usually define "$X$ is infinite" to mean there is an infinite sequence of distinct members of $X$. This is a stronger statement, in a constructive setting, than "$X$ is not finite". In that setting, although proof 3 shows them that the set of primes is not finite, it does not show them that the set of primes is infinite. But the original direct proof (proof 2) does show them this, because proof 2 is also constructively valid (with appropriate axioms for number theory).
The fact that the proof is constructively valid is closely related to the fact that it gives an algorithm for enumerating an infinite set of primes. Even for mathematicians who are unworried about constructive math, that algorithm is likely to be of interest. A key intuition from logic is that these two topics (constructive provability and algorithms) are closely intertwined.
This entire issue is somewhat similar to the distinction between proof by contrapositive and proof by contradiction, which I wrote about at https://math.stackexchange.com/a/705291/630