Each of your Riemann surfaces has a unique structure of a smooth projective algebraic curve and for such a curve $A$ the field of meromorphic functions reduces to the field of rational functions: $M(A)=\text {Rat}(A)$.
This is the most elementary example of a general principle discoverd by Serre and affectionately named GAGA [it has nothing to do with a certain Lady singer, despite question 4) of this post]
Hence $M(A)=M(B)$ implies $\text {Rat}(A)=\text {Rat}(B)$.
An amazing theorem of the algebraic geometry of curves then implies that the algebraic curves $A$ and $B$ are isomorphic because their rational function fields are isomorphic, and so a fortiori are their underlying Riemann surfaces: $A$ is indeed isomorphic to $B$ in the category of Riemann surfaces .
Notice that your Riemann surface $C$ and your morphisms $f,g$ haven't been used at all!