I find proving equalities like this way more "intuitive" using the universal properties. You might want to take the following approach.
Given $f:X\to Y$ and a sheaf $\mathscr{F}$ on $X$, the \emph{direct image} sheaf $f_*\mathscr{F}$ (on $Y$) is defined as $f_*\mathscr{F}(U)=\mathscr{F}(f^{-1}U)$. In the language of category theory the functor $f^{-1}$ (that you defined) is the left-adjoint to direct image functor $f_*$. More explicity, given any sheaf $\mathscr{F}$ on $X$ and any sheaf $\mathscr{G}$ on $Y$ one has a natural bijection of sets:
$$
\alpha: \mathrm{Hom}_Y(\mathscr{G}, f_*\mathscr{F})\to \mathrm{Hom}_{X}(f^{-1}\mathscr{G}, \mathscr{F})
$$
where by $\mathrm{Hom}_X(\mathscr{F_1}, \mathscr{F}_2)$ I mean the set of morphisms of sheaves from $\mathscr{F}_1$ to $\mathscr{F}_2$. You might want to first find such $\alpha$. This is called the adjoint property (I'll provide hints on how to do this at the end.
Using the adjoint property prove that thre is a natural bijection
$$
\beta:\mathrm{Hom}_X (f^{-1}(g^{-1}\mathscr{H}), \mathscr{F)}\to
\mathrm{Hom}_X ((f\circ g)^{-1}\mathscr{H}, \mathscr{F})
$$
for any sheaf $\mathscr{H}$ on $Z$ and any sheaf $\mathscr{F}$ on $X$. In particular let $\mathscr{F}=f^{-1}(g^{-1}\mathscr{H})$, with its bijeciton
$$
\beta:\mathrm{Hom}_X (f^{-1}(g^{-1}\mathscr{H}), f^{-1}(g^{-1}\mathscr{H}))\to
\mathrm{Hom}_X ((f\circ g)^{-1}\mathscr{H}, f^{-1}(g^{-1}\mathscr{H}))
$$
Now choose the identity morephism $\mathrm{id}\in \mathrm{Hom}_X (f^{-1}(g^{-1}\mathscr{H}), f^{-1}(g^{-1}\mathscr{H}))$. What is $\beta(\mathrm{id})$ now? What does say about $(f\circ g)^{-1}$ and $f^{-1}\circ g^{-1}$?
Adjoint property: Consider a morphism $\phi: \mathscr{G}\to f_*\mathscr{F}$, meaning for each open set $V\subset Y$, one has $\phi(V): \mathscr{G}(V)\to \mathscr{F}(f^{-1}(V))$ compatible with restriction. Take an open set $U\subset X$, and suppose $V\subset Y$ is such that $f(U)\subset V$, then $U\subset f^{-1}(V)$, therefore using a restriction map we have a function $\mathscr{F}(f^{-1}(V))\to \mathscr{F}(U)$. Gathering all of this you will find a family of maps
$$
\psi_V: \mathscr{G}(V)\to \mathscr{F}(U)
$$
for all $V\supset f(U)$. By universal property of direct limit then there exists a map, compatible with all these maps,
$$
\omega(U): f^+\mathscr{G}(U)\to \mathscr{F}(U)
$$
I leave it to you to check this naturally extends to a morphism $\omega: f^{-1}\mathscr{G}\to \mathscr{F}$ (use universal propert of sheafification). Define $\alpha(\phi)=\omega$.
Going in the reverse direction, take a morphism $\omega(U): f^{-1}\mathscr{G}(U)\to \mathscr{F}(U)$. Take an open set $V\subset Y$ and let $U=f^{-1}(V)$. Then $f^{-1}\mathscr{G}(U)=\mathscr{G}(V)$, and using $\omega$, we a map $\phi(V): \mathscr{G}(V)\to f_*\mathscr{F}(V)$. Show that $\phi$ is indeed a morphism of sheaves. Then prove that this map is inverse to $\alpha$.
The point here is that the forgetful functor $\mathbf{Ab\to Set}$ preserves filtered colimits, and that the colimit you're taking here is always filtered, so you get a description of that type, with the set coproduct (although you could also have a definition with direct sums)
This will work whenever your forgetful functor preserves filtered colimits, e.g. for rings, modules over a ring (or a sheaf of rings), ...
Best Answer
As you say, it's the colimit of $\mathscr G(V)$ where $V$ runs over all the open sets. The partially ordered set of the open sets of $V$ has a minimum, which is $\varnothing$. This makes the colimit very easy to compute, namely it's $\mathscr G( \varnothing)$.
Let us check the universal property. Suppose that for some $A$ we have compatible maps $\mathscr G(V)\to A$ for every $V$. Then in particular we have a unique map $\mathscr G(\varnothing)\to A$ that makes everything commute.
So $\Gamma(\varnothing,f^{-1}\mathscr G) = \Gamma(\varnothing,\mathscr G)$. If you have said that $\mathscr G$ is a sheaf, then $\mathscr G(\varnothing)$ is the final object (i.e. $\{*\}$ is we're talking about sheaves of sets or the trivial group if it's sheaves of groups). I'm not sure if this is a convention or it follows from the definition (it seems that it follows from the definition... see https://stacks.math.columbia.edu/tag/006U ).