Let $X$ be a smooth projective curve over a field $k$, and fix an effective divisor $D$ on it. Assume that we have a non-zero rational function $f$ whose divisor satisfies $\operatorname{div}(f) \geq -D$ i.e. $f$ belongs to the Riemann-Roch space $L(D)$.
Why is it true that the degree of the morphism $f$ is upper-bounded by the degree of $D$, i.e. $\deg(f) \leq \deg(D)$ ?
There is a rough explanation here https://math.stackexchange.com/q/2351537, but I don't get it. In general $f^{-1}([0:1])$ and $f^{-1}([1:0])$ have cardinality smaller than $\deg(f)$ - equality holds for almost every $p \in \Bbb P^1_k$. So I am not sure how to conclude.
(As mentioned in a comment, we need $D$ effective, otherwise $D = -\rm div(f)$ is a counter-example).
There is the notion of multiplicity that you are missing. The degree of $f$ is the number of points above $[1:0]$ counted with multiplicity (aka ramification). This is the contribution of negative terms in $\mathrm{div}(f)$. Said contribution is larger than $-D$, which is a negative divisor, so it has degree higher than $-D$. Setting signs right, it follows $\deg{f} \leq \deg{D}$.