That’s a good question! Note that it is a (very) special case of the GAGA theorems/philosophy – in ”complete enough” situations (usually properness), analytic objects and morphisms should come from algebraic geometry.
The first part of the argument is, I believe, to study the case $C=\mathbb{P}^1$, which is classical: $k(C)=k(t)$ almost by definition, and a meromorphic function on $\mathbb{P}^1$ has (after multiplying by a polynomial factor) poles only at infinity, so it has a power series expansion with finitely many terms (otherwise the singularity at infinity is essential) ie is a polynomial.
Next, we treat the relative cases separately: let $f: Y \rightarrow X$ be a nonconstant morphism of smooth projective algebraic curves (resp. compact Riemann surfaces coming from smooth projective curves*). We’ll see that the pull-back makes $k(Y)$ (resp. $\mathcal{M}(Y)$) a $k(X)$-algebra (resp. a $\mathcal{M}(X)$-algebra) of dimension exactly (resp. at most) $\deg{f}$.
Assume that this holds. Let $C$ be a smooth projective curve. We can then choose some nonconstant $f \in k(C)^{\times}$ which defines a nonconstant morphism $\varphi: C \rightarrow \mathbb{P}^1$ of algebraic curves and Riemann surfaces as well – and it has the same degree in both interpretations (because the degree is the cardinality of every fiber but finitely many).
Because pull-back commutes to analytification, it follows that $k(C) \subset \mathcal{M}(C)$ is an inclusion of $\varphi^*-k(\mathbb{P}^1)$-vector spaces with non-increasing finite dimension – so is an equality.
*in fact, Chow’s lemma and general considerations on Riemann surfaces show that every compact Riemann surface should come from algebraic geometry (as they are projective!). I would even say that the relationship comes from “earlier”: if I recall correctly, much of the theory of compact Riemann surfaces comes from the existence of nonconstant meromorphic functions – that is, their finiteness over $\mathbb{P}^1$.
All that remains to do is show the relative case. For algebraic curves, this is more or less the definition of degree. For Riemann surfaces, it’s trickier, and I think this argument needs quite more detail.
Let $f \in \mathcal{M}(Y)$. Define, for every $x \in X$ and $1 \leq i \leq d$, $c_i(x)=\sum_{F \subset \varphi^{-1}(x), |F|=i}{\prod_{y \in F}{f(y)}}$. $c_i$ is clearly holomorphic at every point above which $\varphi$ is not ramified and $f$ has no pole (so, almost every point). I believe that we can see in local charts that $c_i$ is meromorphic at the remaining points.
The trick is that $\sum_{i=0}^d{(-1)^{i}c_i(\varphi(y))f^{d-i}(y)}=0$ for almost all $y$, thus $f$ is algebraic of degree $d$ over $\mathcal{M}(X)$ (where $d$ is the degree of $f$). Thus, the pull-back $\mathcal{M}(X) \rightarrow \mathcal{M}(Y)$ is an integral extension of characteristic zero fields such that every monogenous subextension has degree at most $d$. The conclusion is then “elementary” field theory in characteristic zero.