The Universal property characterizes the cartesian product the following way:
Theorem Let $Z$ be a set and $\pi^Z_1 : Z \to X$ and $\pi^Z_2:Z \to Y$ be any triple which satisfies the same universal property. Then, there exists some bijection $F : Z \to X \times Y$ such that for $j=1,2$ we have
$$\pi_j \circ F = \pi_j^Z$$
Proof Since $\pi^Z_1 : Z \to X$ and $\pi^Z_2:Z \to Y$, by the Universal property from your Theorem there exists an unique $F : Z \to X \times Y$ such that
$$\pi_j \circ F = \pi_j^Z$$
Now, since $\pi_1: X \times Y \to X$ and $\pi_2 : X \times Y \to Y$, by the universal property for $Z$ there exists some $G : X \times Y \to Z$ such that
$$\pi^Z_j \circ G = \pi_j$$
Finally look at $F \circ G : X \times X \to X \times X$. Both $F \circ G$ and $Id$ satisfy the universal property for $<f,g>$
$$f=\pi_1 : X\ times Y \to X \,;\, g=\pi_2 : X \times Y \to Y$$
in your diagram. By the uniqeueness part we get
$$F \circ G= Id$$
Same way, both $G \circ F$ and $Id$ satisfy the universal property for $Z$ hence $G \circ F =Id$.
This shows that $F,G$ are inverses of eachother.