Denote by $\Bbb Z[x]$ the polynomial ring over $\Bbb Z$ in one variable. Prove that for all rings $R$ and all $r \in R$, there exists a unique ring homomorphism $\varphi: \Bbb Z[x] \to R$ such that $\varphi(x)=r$.
The problem is from Leinster's basic category theory. I'm slightly confused about the argument for $\varphi$ here. Is $x$ supposed to mean any polynomial $P$ with $x$ as it's variable here or is it just the polynomial $P(x)=x$? Also how should one approach these universal property proofs in general? I feel like there is nowhere to start here.
If we write "$\mathbb Z[x]$ the polynomial ring over $\mathbb Z$ in one variable" we implictly mean that $x$ is this variable. This variable is then fixed. Writing $\varphi(x)=r$ just refers to the image of the free variable $x$ along $\varphi$ not to an arbitrary polynomial $p(x)\in\mathbb Z[x]$ (there are choices of $r$ for which there then would'nt be any ring homomorphism at all; can you think of one?).
With this out of the way, let's talk about the heart of the question.
Universal properties express the existence of some unique maps solving certain factorization problems. At the same time, these problems often encapsulate how one would go on defining the unique maps. Indeed, by definition they have to fit into some commutative diagrams (which is a more natural language of expressing universal properties anyway; but drawing them here is... not fun).
Take the example of defining a unique ring homomorphism $\varphi\colon\mathbb Z[x]\to R$ such that $\varphi(x)=r$ for some fixed $r\in R$ (well, that's not the best example for what I'm describing above but let's see how far we can get).
I assume that we are talking about (commutative) unital rings. Then there is always a unique ring homomorphism $\mathbb Z\to R$ completely determined by $1\mapsto 1_R$. The latter is usually required of ring homomorphisms of unital rings. The problem in Leinster actually asks about extending this unique map to a ring homomorphism $\varphi\colon\mathbb Z[x]\to R$ after we have picked some $r\in R$.
Extending $1\mapsto 1_R$ means that we only have to newly define the homomorphism for the new element $x\in\mathbb Z[x]$ or, put differently, we want that the composition $\mathbb Z\to\mathbb Z[x]\to R$ is still $1\mapsto 1_R$. Here we see from the ring homomorphism axioms that it suffices to define the image of $x$ as
$$ \varphi(ax^n+bx^m)=\varphi(ax^n)+\varphi(bx^m)=\varphi(a)\varphi(x)^n+\varphi(b)\varphi(x^m)=a\varphi(x)^n+b\varphi(x)^m $$
which is what Ennar referred to in the comments. If we now set $\varphi(x)=r$ we not only see that this defines a ring homomorphism if we extend in additively and multiplicatively, but it is also the unique such homomorphism as $\varphi(x)=r$ completely determines any ring homomorphism $\mathbb Z[x]\to R$ (remember that our maps necessarily preserve the multiplicative identities).
Reformulating the problem as factorization problem: For any choice of $r\in R$ there is a unique $\varphi\colon\mathbb Z[x]\to R$ extending the canonical map $i\colon\mathbb Z\to R,\,1\mapsto 1_R$ along the inclusion $\iota\colon\mathbb Z\to\mathbb Z[x]$. The equality $i=\varphi\circ\iota$ immediately tells us that we only need to define $\varphi$ on $x$ (by the above computation) and once this is done we get an unique solution to the problem. This is what I was refering to earlier.