The free product is the coproduct in the category of groups. Take the construction of its elements using words as in https://en.wikipedia.org/wiki/Free_product.
Obviously, in a free product there can be no nontrivial result of operations between elements of different groups. For example, $g1h1$ could not be equal to $h2$, an element of $H$.
What in the universal mapping property of coproducts forbids this kind of operation in a free product ? The commutative diagrams (https://en.wikipedia.org/wiki/Coproduct) are defined from $H$ and $G$. Why would they not commute if additional "nontrivial" operations across "subgroups" (across images of $H$ and $G$ in $H * G$) are defined ?
Maybe an example could help me. If there is such an operation across subgroups, what would be violated in the definition of the coproduct ?
One way to see this is known as "van der Waerden's trick" (or a variant of it). Namely, let $W$ be the set of reduced words in the definition, and consider the symmetric group $S(W)$. Then for each element $g \in G$, we can define an element of $S(W)$ by: if $w \in W$ begins with $g' \in G$, then replace $g'$ with $(gg')$ (as a single initial symbol) and also remove it if it happens that $g' = g^{-1}$. Otherwise, prepend $g$ to $w$. (And of course, if $g = e$ then send $g$ to the identity permutation.)
It is straightforward (though involving several different cases to check, depending on whether the "removal" happens at each step or not) to prove that this induces a group homomorphism $G \to S(W)$. We can also construct a group homomorphism $H \to S(W)$ in a similar way. By the coproduct universal property, these two maps induce a unique group homomorphism $H * G \to S(W)$.
But now, if we have any $g \in G$, $h \in H$, then applying $h$ to the empty string results in $h$, and then applying $g$ results in the string $gh$. Therefore, the image of $gh$ in $S(W)$ cannot be equal to the image of $h'$ in $S(W)$ which sends the empty string to just $h'$. That implies that $gh \ne h'$ in $H*G$. A very similar argument shows that in general, each reduced word in $W$, when converted to its corresponding element of $H*G$, has a distinct image in $S(W)$.