For a counterexample, let $G_i=\mathbb{Z}$ be the integers and let $H_i=\frac1i\mathbb{Z}$, for positive natural numbers $i$. The union $\bigcup_i G_i=\mathbb{Z}$, but $\bigcup_i H_i=\mathbb{Q}$.

For the revised question, where you want $G_i$ and $H_i$ distinct, there are still counterexamples, such as $G_i=i\mathbb{Z}$ and $H_i=\frac1i\mathbb{Z}$.

On a positive note, if you have a bit more coherence in your isomorphisms, then you can make the affirmative conclusion. That is, if we can find particular isomorphisms $\pi_i:G_i\cong H_i$ which agree on their common domains, then they will build together into an isomorphism of $G$ and $H$. That is, what you want is not merely that $G_i\cong H_i$, but rather that the way that $G_i$ sits inside $G$ is the same as the way $H_i$ sits inside $H$. More generally, if $I$ is not just a naked index set, but is a directed set, such that when $i\lt j$ in this order then we have maps $G_i\to G_j$ and $H_i\to G_j$ and the isomorphisms $G_i\cong G_j$ make a commutative system, then the direct limit $G$ of the $G_i$'s will be isomorphic to the direct limit $H$ of the $H_i$'s by universal property arguments.

1

For a counterexample, let $G_i=\mathbb{Z}$ be the integers and let $H_i=\frac1i\mathbb{Z}$, for positive natural numbers $i$. The union $\bigcup_i G_i=\mathbb{Z}$, but $\bigcup_i H_i=\mathbb{Q}$.