Given the representable functor, one way you can find the morphisms and prove their various compatibilities is by looking at judicious ``test objects."
More precisely, suppose that $G$ is an $S$-scheme whose functor of points $T\mapsto G(T)$ factors through the category of groups, i.e., $G(T)$ is a group for each $S$-scheme $T$, and if $T_1\to T_2$ is an $S$-morphism, $G(T_2)\to G(T_1)$ is a group homomorphism.
The multiplication is supposed to be a morphism $m:G\times_S G\to G$, i.e., an element of $G(G\times_SG)$. Do we know any arrows in this group? The only completely obvious ones are the projections $p_1,p_2:G\times_SG\to G$. So a reasonable thing to try is $m:=p_1*p_2$, where $*$ denotes the multiplication on the group $G(G\times_SG)$. For the identity section, one takes the identity element of the group $G(S)$, and for the inverse, look at the inverse of $\mathrm{id}_G$ in $G(G)$.
Another, perhaps more direct way to do this, is to observe that the functoriality in the functor of points definition says precisely that there is a natural transformation of functors $m:h_G\times h_G\to h_G$ which gives, for each $S$-scheme $T$, the group operator $G(T)\times G(T)\to G(T)$. Similarly there is a natural transformation $\epsilon:h_S\to h_G$ such that the image of the unique point of $S(T)$ in $G(T)$ is the identity element for the group operator given by $m$, for all $S$-schemes $T$. Likewise for the inversion. All these natural transformations, by Yoneda's lemma, are induced by uniquely determined morphisms of $S$-schemes, and the various compatibilities (associativity and so forth) hold because they hold on $T$-points for every $S$-scheme $T$.
EDIT: As Matt E indicates in the comments, the real content of this answer is the "perhaps more direct way." What I'm doing in the first few paragraphs is explicitly finding the morphisms inducing given natural transformations of the functor of points $h_G$, i.e., implementing Yoneda's lemma explicitly (for morphisms from $G\times G$ to $G$, from $S$ to $G$, and from $G$ to $G$, respectively). So it's not really a different way of doing it. Also, as Kevin Carlson remarks, and this is definitely worth pointing out, this has nothing to do with schemes. One can work with group objects in any category with products and do the same thing.