Theorem: $(X_1 \times X_2) \times X_3$ together with the obvious projection arrows forms a ternary product of $X_1, X_2, X_3$.
Proof Assume $[X_1 \times X_2, \pi_1, \pi_2]$ is a product of $X_1$ with $X_2$, and $[(X_1 \times X_2) \times X_3, \rho_1, \rho_2]$ is a product of $X_1 \times X_2$ with $X_3$.
Take any object $S$ and arrows $f_i\colon S \to X_i$. By our first assumption, (a) there is a unique $u \colon S \to X_1 \times X_2$ such that $f_1 = \pi_1\circ u$, $f_2 = \pi_2\circ u$. So by our second assumption (b) there is then a unique $v \colon S \to (X_1 \times X_2) \times X_3$ such that $u = \rho_1 \circ v$, $f_3= \rho_2\circ v$.
Therefore $f_1 = \pi_1\circ \rho_1 \circ v$, $f_2 = \pi_2 \circ \rho_1 \circ v$, $f_3 = \rho_2 \circ v$
So now consider $[(X_1 \times X_2) \times X_3, \pi_1 \circ \rho_1, \pi_2 \circ \rho_1, \rho_2]$. This, we claim, is indeed a ternary product of $X_1, X_2, X_3$. We've just proved that $S$ and arrows $f_i\colon S \to X_i$ factor through the product via the arrow $v$. It remains to confirm $v$'s uniqueness in this new role.
Suppose we have $w \colon S \to (X_1 \times X_2) \times X_3$ where $f_1 = \pi_1 \circ \rho_1 \circ w$, $f_2 = \pi_2 \circ \rho_1 \circ w$, $f_3 = \rho_2 \circ w$. Then $\rho_1 \circ w\colon S \to X_1 \times X_2$ is such that $f_1 = \pi_1\circ (\rho_1 \circ w)$, $f_2 = \pi_2\circ (\rho_1 \circ w).$ Hence by (a), $u = \rho_1 \circ w$. But now invoking (b), that together with $f_3 = \rho_2 \circ w$ entails $w = v$. $\quad\Box$
(That's Theorem 76 in these Notes on Basic Category Theory.)
Under a suitable framework, homotopy colimits and limits satisfy a "local homotopical universal property". For example, homotopy colimits represent "homotopy coherent cones". See section 10 of Shulman's "Homotopy limits and colimits and enriched homotopy theory" for the definitions and a discussion. Riehl's Categorical homotopy theory also discusses this in section 7.7.
Homotopy colimits and limits also have a global definition in terms of derived functors when they make sense. So this could also serve as an universal property defining them.
Best Answer
"why is that true ?" : we define the tuple $(P, \pi_A,\pi_B)$ to be a product if it satisfies this property. So it is true for the product because we defined products to be those things that satisfy it.
"How can this possibly true" : think about the category of sets, and the usual cartesian product of sets $A\times B$ with projections $(a,b)\mapsto a, (a,b)\mapsto b$. Can you try to prove and understand why it satisfies this condition ?
Now can you try to show something similar for the cartesian product of groups ? of rings ?
Note that a product in a category $C$ need not have anything to do with the usual cartesian product of sets, even when $C$ is a category of "sets with structure". It is very often true that it is related to the product of sets for categories of sets with algebraic structures, but then that is something you have to prove, and it does not follow from the definition of a product.