Say I have compact Riemann surfaces $X$, $Y$. Is there necessarily a Riemann surface $Z$ which maps holomorphically onto both $X$, $Y$?

Here is some construction. $X$ and $Y$ are smooth projective algebraic complex curves. So the complex surface $X \times Y$ is projective (e.g. by Segre embedding) and so admits a very ample line bundle $L$. By Bertini theorem, the vanishing locus of a general section of $L$ is a smooth projective complex curve $Z$ (so a compact Riemann surface) in $X \times Y$. The composition of the inclusion of $Z$ in $X \times Y$ with the projection on $X$ (or $Y$) is not constant: if it were constant, $Z$ would be contained in some $Y$ fiber, having zero intersection with a generic $Y$ fiber, and contradicting ampleness of $L$.

Choose non-constant meromorphic functions $f:X\to \mathbb P^1$ and $g:Y\to \mathbb P^1$ and denote by $Z$ the normalization of the fiber product $X\times_{\mathbb P^1} Y=\{(x,y)\in X\times Y; f(x)=g(y)\}$. It comes equipped with two maps $\tilde f:Z\to X$ and $\tilde g:Z\to Y$ such that the following diagramm commutes

$\require{AMScd}$ \begin{CD} Z @>{\tilde f} >> X\\ @V {\tilde g} V V @VV f V\\ Y @>>{ g}> \mathbb P^1 \end{CD}

Note that $Z$ may be disconnected, but the restriction of $\tilde f$ and $\tilde g$ to any of its connected components are surjective (because the fibers of those two maps are finite).