Proving the universal mapping property for polynomial rings
Solution 1:
Let $A = B$ and $a_i = f(x_i)$. The first part says that there exists a unique $F$-homomorphism $\varphi \colon F[x_1,\dotsc,x_n] \to B$ such that $\varphi(x_i) = f(x_i)$ for each $i$.
Let $A = F[x_1,\dotsc,x_n]$ and $a_i = x_i$. The hypothesis in the second part says that there exists a unique $F$-homomorphism $\psi \colon B \to F[x_1,\dotsc,x_n]$ such that $\psi(f(x_i)) = x_i$ for each $i$.
Consider $\psi \circ \varphi \colon F[x_1,\dotsc,x_n] \to F[x_1,\dotsc,x_n]$. It is an $F$-homomorphism satisfying $\psi \circ \varphi (x_i) = x_i$. But, $\operatorname{id}_{F[x_1,\dotsc,x_n]}\colon F[x_1,\dotsc,x_n] \to F[x_1,\dotsc,x_n]$ is also an $F$-homomorphism satisfying $\operatorname{id}_{F[x_1,\dotsc,x_n]}(x_i) = x_i$. Taking $A = F[x_1,\dotsc,x_n]$ and $a_i = x_i$, the uniqueness condition in the first part says that $\operatorname{id}_{F[x_1,\dotsc,x_n]} = \psi \circ \varphi$.
Consider $\varphi \circ \psi \colon B \to B$. It is an $F$-homomorphism satisfying $\varphi \circ \psi (f(x_i)) = f(x_i)$. But, $\operatorname{id}_B \colon B \to B$ is also an $F$-homomorphism satisfying $\operatorname{id}_B(f(x_i)) = f(x_i)$. Taking $A = B$ and $a_i = f(x_i)$, the uniqueness condition in the hypotheses of the second part says that $\operatorname{id}_B = \varphi \circ \psi$.
Hence, $F[x_1,\dotsc,x_n] \cong B$.