Groups $G,H$ with surjective homomorphisms that are quotient of each other

There is an example of two non-isomorphic groups with this property in Theorem 3 of the paper by Baumslag and Solitar on non-Hopfian groups, whcih you can access here.

The two groups are $\langle a,b \mid a^{-1}b^2a=b^3 \rangle$ and $\langle c,d \mid c^{-1}d^2c=d^3, ([c,d]^2c^{-1})^2=1 \rangle$.


As already answered, any example has to be a non-Hopfian group, and there are easy examples that are abelian (and infinitely generated) and some more subtle (but widely studied) finitely generated examples, as in Derek's answer.

However the given property ($\ast$) is weaker than hopfian, where Property ($\ast$) for a group $G$ is defined as: whenever $H$ is a quotient of $G$ admitting $G$ as a quotient, then $H$ is isomorphic to $G$.

Of course Hopfian implies ($\ast$), but the converse fails: for instance, if $C(p^\infty)$ is the Pr\"ufer group and $G=C(p^\infty)^{\mathbf{N}}$ is the direct sum of countably many copies of $C(p^\infty)$, then the abelian group $G$ is clearly non-Hopfian but satisfies ($\ast$).

For a finitely generated example, consider the group $A_n$ of $n\times n$ upper triangular matrices over $\mathbf{Z}[1/p]$ ($p$ prime) with $a_{11}=a_{nn}=1$, and $B_n$ the quotient of $A_n$ by the (central) cyclic subgroup generated by the elementary matrix $e_{1n}(1)$. Then $B_n$ is finitely generated for $n\ge 3$; (it was introduced by Hall for $n=3$ and Abels for $n\ge 4$, in which case it is finitely presented) is non-Hopfian. But it satisfies ($\ast$) by a simple argument.

However this seems quite exceptional and "most" non-Hopfian groups ought not to satisfy ($\ast$).