Can two topological spaces surject onto each other but not be homeomorphic? Let $X$ and $Y$ be topological spaces and $f:X\rightarrow Y$ and $g:Y\rightarrow X$ be surjective continuous maps.  Is it necessarily true that $X$ and $Y$ are homeomorphic?  I feel like the answer to this question is no, but I haven't been able to come up with any counter example, so I decided to ask here.  
 A: Others have answered, but maybe these comments will also be useful for this thread. A stronger equivalence (replace “surjective” with “bijective” in both places), which is still strictly weaker than being homeomorphic, was studied by several people in the early days of topology (Banach,  Kuratowski, Hausdorff, Sierpinski, etc. in the 1920's). I believe this stronger equivalence originates from Frechet (1910), who called it type de dimensions. There is a lot about this relation in Sierpinski's General Topology (where it's called dimensional type; see pp. 130-133, 137, 141, 142, 144, 145, 163, 165) and in Kuratowski's Topology (where it's called topological rank).
A: The circle $S^1$ surjects onto the interval $I = [-1,1]$ by projection in (say) the $x$-coordinate, while the interval $I$ surjects onto the circle by wrapping around, say $f(x) = (\cos \pi x, \sin \pi x)$.
Added: Why is the circle $S^1$ not homeomorphic to the interval $I = [-1,1]$ ? The usual proof looks at cut points, i.e. a point $x$ whose removal from a topological space $X$ results in a disconnected space $X\backslash\{x\}$.  Since this is a purely topological property, two homeomorphic spaces will have an equal number of cut points.
Note that $S^1$ has no cut points; removal of any single point from the circle leaves a connected open arc.  However a closed interval $I$ has infinitely many cut points because removing any point except one of the two endpoints disconnects it into two disjoint subintervals.
The same observation serves to show the spaces in Karolis Juodelė's answer are not homeomorphic: $[0,1]$ has cut points and $[0,1]^2$ does not.
See Seth Baldwin's comment below for an alternative idea, something that will not disconnect the interval $I$ that does disconnect the circle!
A: Just to be different, here’s an example that isn’t related to the Hahn-Mazurkievicz theorem. The example is originally due (with a different purpose) to K. Sundaresan, Banach spaces with Banach-Stone property, Studies in Topology (N.M. Stavrakas & K.R. Allen, eds.), Academic Press, New York, 1975, pp. 573-580; the argumentation is mine, On an example of Sundaresan, Top. Procs. 5 (1980), pp. 185-6. The surjections are $1$-$1$ save at a single point each, where they are $2$-$1$.
Let $X=\omega^*\cup(\omega\times 2)$, where $\omega^*=\beta\omega\setminus\omega$, and $2$ is the discrete two-point space, let $\pi:X\to\beta\omega$ be the obvious projection, and endow $X$ with the coarsest topology making $\pi$ continuous and each point of $\omega\times 2$ isolated. Let $N=\omega\times 2$, for $n\in\omega$ let $P_n=\{n\}\times 2$, and let $\mathscr{P}=\{P_n:n\in\omega\}$. A function $f:X\to X$ preserves pairs if $f[P_n]\in\mathscr{P}$ for all but finitely many $n\in\omega$.

Lemma. Let $f:X\to X$ be an embedding; then $f$ preserves pairs.
Proof. Suppose that $f$ does not preserve pairs. Since $f$ is injective, an easy recursion suffices to produce an infinite $M\subseteq\omega$ such that $(\pi\circ f)\upharpoonright\bigcup\{P_n:n\in M\}$ is injective. Let $M_i=M\times\{i\}$ for $i\in 2$. Then $$\left(\operatorname{cl}_XM_i\right)\setminus N=\left(\operatorname{cl}_{\beta\omega}M\right)\setminus\omega\ne\varnothing$$ for $i\in 2$, so $$\left(\operatorname{cl}_Xf[M_0]\right)\setminus N=\left(\operatorname{cl}_Xf[M_1]\right)\setminus N\ne\varnothing\;.$$ But $$\left(\operatorname{cl}_Xf[M_i]\right)\setminus N=\left(\operatorname{cl}_{\beta\omega}f[M_i]\right)\setminus\omega$$ for $i\in 2$, $\pi\big[f[M_0]\big]\cap\pi\big[f[M_1]\big]=\varnothing$, and disjoint subsets of $\omega$ have disjoint closures in $\beta\omega$, so $\operatorname{cl}_Xf[M_0]\cap\operatorname{cl}_Xf[M_1]=\varnothing$; this is the desired contradiction. $\dashv$

Now let $p$ be any point not in $X$, and let $Y=X\cup\{p\}$, adding $p$ to $X$ as an isolated point. 

Proposition. $Y$ is not homeormorphic to $X$.
Proof. Suppose that $h:Y\to X$ is a homeomorphism; it follows from the lemma that $h\upharpoonright X$ preserves pairs. Let $$A=\bigcup\Big\{P_n\in\mathscr{P}:h[P_n]\in\mathscr{P}\Big\}\cup\omega^*\;.$$ Then $\big|X\setminus h[A]\big|$ is finite and even, $|Y\setminus A|$ is finite and odd, and $h\upharpoonright(Y\setminus A)$ is a bijection between these two sets, which is absurd. $\dashv$

Finally, the maps 
$$f:Y\to X:y\mapsto\begin{cases}
y,&\text{if }y\in X\\
\langle 0,0\rangle,&\text{if }y=p
\end{cases}$$
and
$$g:X\to Y:x\mapsto\begin{cases}
x,&\text{if }x\in\omega^*\\
p,&\text{if }\pi(x)=0\\
\langle n-1,i\rangle,&\text{if }x=\langle n,i\rangle\text{ and }n>0
\end{cases}$$
are continuous surjections.
By the way, each of $X$ and $Y$ embeds in the other, so these spaces witness the lack of a Schröder-Bernstein-like theorem for compact Hausdorff spaces and embeddings.
A: There is a continuous surjective map from $[0, 1]$ to $[0, 1]^2$ - the Peano curve. There is also a map from $[0, 1]^2$ to $[0, 1]$ - $f(x, y) = x$. However the two spaces are not homoemorphic.
A: More generally: any two connected, locally connected, compact, second-countable spaces have your property.  (Hahn-Mazurkiewicz Theorem)
