If we want to define a product of objects in a category (cf. Wikipedia Page), we need to find a morphism and it must be unique.
In our notes, the professor gives some examples such as the product of groups in the category of groups. In these examples, he explicitly constructs the morphism (needed in the universal property) but he does not prove the uniqueness. Do we always have the uniqueness of the morphism in the universal property for free? Or we have to prove it by some way?
Thanks for help.
No, uniqueness of the morphism in the definition of a universal property does not come for free. It has to be proven.
You mention the direct product of groups. If $f : T \to A$, $g : T \to B$ are homomorphisms of groups, we need to provide a unique homomorphism $h : T \to A \times B$ with $p_1 \circ h = f$ and $p_2 \circ h = g$. Writing down what these equations mean, we get $h(t) = (f(t),g(t))$. Thus, uniqueness follows. We only have to verify that the map which is defined by $h(t) := (f(t),g(t))$ is actually a group homomorphism $-$ which easily follows from $f$ and $g$ having this property.
If we omit uniqueness, we get more groups satisfying the (non-)universal property of product. Take any group $P$ which admits a split epimorphism $P \twoheadrightarrow A \times B$ (for example $A \times A \times B$). Then we have $p'_1 : P \twoheadrightarrow A \times B \to A$, $p'_2 : P \twoheadrightarrow A \times B \to B$, and for all $f,g$ as above we can find $h' : T \to P$ with $p'_1 \circ h' = f$ and $p'_2 \circ h' = g$, namely the composition of $h : T \to A \times B$ (as defined above) and the section $A \times B \hookrightarrow P$.
This is connected to the notion of a weak limit, which modifies the notion of a limit by omitting uniqueness of the morphism. For example, a weakly terminal object is an object $T$ such that every object $A$ admits a morphism $A \to T$ (which is not necessarily unique). In the category of groups, every object is weakly terminal. A more interesting example is the category of algebraic extensions of a field $K$. Any algebraic closure of $K$ is a weakly terminal object, but it is not terminal since embeddings of algebraic extensions into the algebraic closure are not unique. Also, $\mathrm{Aut}_K(\overline{K})$ is not trivial, it is the absolute Galois group of $K$. The category of algebraic extensions of $K$ has no terminal object.