Are there nonisomorphic, finitely generated groups that surject onto each other? Are there nonisomorphic, finitely generated groups that surject (homomorphically) onto each other?
For example of the 'dual' problem, the free group on $2$ generators $F_2$, and the free group on $3$ generators $F_3$ inject into each other; but there is no surjection from $F_2 \to F_3$ (intuitively, if there was was, since $F_3$ surjects onto $\mathbb{Z}^3$, there would therefore be a surjection $F_2 \to \mathbb{Z}^3$, but the image of such a map could only be a $2$-dimensional sublattice of $\mathbb{Z}^3$, so we have a contradiction)
 A: Let's suppose that we have two nonisomorphic finitely generated groups $G$ and $H$ with surjective homomorphisms $\varphi: G \to H$ and $\psi: H \to G$. Then the first isomorphism theorem gives us
\begin{align*}
\frac{G}{\ker \varphi} &\simeq H & \frac{H}{\ker \psi} &\simeq G
\end{align*}
Since $G$ and $H$ are not isomorphic, both $\ker \varphi$ and $\ker \psi$ must be nontrivial. Additionally, we can consider the composite maps $\psi \circ \varphi: G \to G$ and $\varphi \circ \psi: H \to H$. These maps, being compositions of surjections, are themselves surjective homomorphisms, and they each have nontrivial kernel. We find
\begin{align*}
\frac{G}{\ker(\psi \circ \varphi)} & \simeq G & \frac{H}{\ker(\varphi \circ \psi)} &\simeq H
\end{align*}
In other words, both $G$ and $H$ are isomorphic to nontrivial quotients of themselves. This condition is actually rather subtle. A group that is not isomorphic to any of its nontrivial quotients is called Hopfian, so what we require is a pair of finitely generated, non-Hopfian groups.
The classical example of finitely generated, non-Hopfian groups are Baumslag-Solitar groups. These groups have two generators with one relation on them. In particular, we define
$$\mathrm{BS}(m,n) = \langle a,b : a^{-1}b^m a = b^n \rangle$$
In other words, $\mathrm{BS}(m,n)$ is the group generated by two elements $a$ and $b$ subject to the relation that $a^{-1}b^m a = b^n$. The key result that Baumslag and Solitar proved is this:
Theorem (Baumslag-Solitar 1962): The group $\mathrm{BS}(m,n)$ is Hopfian if and only if

*

*$m$ and $n$ share the same prime factors or

*one of $m$ and $n$ divides the other.

In reference to Eric Wofsey's comment, it is a theorem of Mal'cev that all finitely generated, residually finite groups are Hopfian, so indeed we must avoid residually finite groups. If $|m|=|n|$ or $1 \in \{|m|, |n|\}$, then $\mathrm{BS}(m,n)$ is residually finite.
Returning to our main goal, recall that we are interested in the non-Hopfian Baumslag-Solitar groups. The simplest example of this is $\mathrm{BS}(2,3)$, which has the surjection $a \mapsto a, b \mapsto b^2$ that is not an isomorphism.
As much as I'd like to give you a nice example of groups surjecting onto each other using small Baumslag-Solitar groups, I can't seem to come up with one (I don't think such an example exists). I believe, however, that your answer lies in this paper from 2014. Levitt defines two groups $G$ and $H$ as being epi-equivalent if there are surjective group homomorphisms from $G$ to $H$ and from $H$ to $G$. We have (Corollary 6.8)
Theorem (Levitt): Suppose that $\mathrm{BS}(m, n)$ is not Hopfian. There exist infinitely many pairwise non-isomorphic generalized Baumslag-Solitar (GBS) groups epi-equivalent to $\mathrm{BS}(m,n)$ if and only if $|m|$ is not prime, $|n|$ is not prime, and $\gcd(m,n) \neq 1$.
Take $G = \mathrm{BS}(4,6)$. Then this theorem asserts that there are infinitely many GBS groups epi-equivalent to $G$. Because Baumslag-Solitar and GBS groups are finitely generated, this gives the desired example of nonisomorphic, finitely generated groups that surject onto each other.
