The book defined it as given in the last line in this picture:
But here How to prove that the analogue of this theorem is valid for $R$-modules? in the answer a different universal property is used, could anyone explain for me why?
The book defined it as given in the last line in this picture:
But here How to prove that the analogue of this theorem is valid for $R$-modules? in the answer a different universal property is used, could anyone explain for me why?
Copyright © 2021 JogjaFile Inc.

The defining universal property of the product is the one you cite in this question. It is the object which has maps to every factor, and it is terminal among such animals.
However it is also true (and follows from the definition here) that given two families of objects $G_i$ and $H_i$, and morphisms between them $f_i\colon G_i\to H_i$, there is a product morphism $\prod f_i\colon \prod G_i\to\prod H_i.$
Indeed, since $\prod G_i$ has morphisms to each $G_j$, and we may compose it with the morphism $f_j$ to get a morphism to $H_j$, thus we have a family of morphisms from $\prod G_i\to H_j$ for each $j$. Thus by the universal property, we have a morphism $\prod G_i\to\prod H_i,$ which is called $\prod f_i.$
In short, product is a functor. This is the property invoked in the answer you linked.