Within my lecture notes, it is stated that the generating function of $\{ p(n) \}$ is given by $$ P(x) := (1 + x + x^2 + x^3 + \dots )(1 + x^2 + x^4 + x^6 + \dots )(1 + x^3 + x^6 + x^9 + \dots ) \dots $$ That is, the coefficient of $x^n$ in the expansion of $P(x)$ is equal to $p(n)$ (the number of ways of writing $n \in \mathbb{N}$ as the sum of positive integers).
However, I am struggling to see why this is true. Clearly the coefficient of $n$ in this expansion is equal to the number of solutions to the sum $$ a_1 + a_2 + a_3 + \dots = n $$ where $a_1 \in \{ 0,1,2,3,\dots \}, a_2 \in \{ 0,2,4,6 \dots \}, a_3 \in \{ 0, 3,6,9, \dots \}$ and so on. However, this does not account for some partitions of $n$, such as $1+1+1+ \dots + 1$.
It also counts some partitions twice. For example, if we are considering $n=5$ then it would count $2+3$ and $3+2$ as separate partitions.
So what is the reason that there is a correspondence here?
The reason that this is important to understand is because I come across questions which ask me to find the generating function of the number of partitions of $n \in \mathbb{N}$ subject to some condition (i.e. all parts being distinct, etc). The way that these sorts of questions are answered is by starting with the expression for $P(x)$ given above, and then cancelling out certain terms. Without understanding how $P(x)$ is reached, it is difficult to know which terms should be removed.