Suppose the polynomial $f(x)$ has degree $n$ and $g$ has degree $m\ge 1$
If $m\gt n$ then $f(x)=0\cdot g(x) +f(x)$ with $q(x)=0$ and $r(x)=f(x)$
What we are looking for is the degree of $r(x)$ being less than the degree of $g(x)$, so this works.
We treat this as a base case and assume that we have dealt with all cases in which deg$(f)\ge n-1$ and that $n\ge m$
Let the polynomials be $f(x)=a_nx^n+f_n(x)$ and $g(x)=b_mx^m+g_m(x)$ where $a_n, b_m \neq 0$ and deg$(f_n)\lt n$, deg$(g_m)\lt m$
Then we want to write $f(x)=\cfrac {a_n}{b_m}\cdot x^{n-m}g(x)+f_n(x)-\cfrac {a_n}{b_m}\cdot x^{n-m}g_m(x)$ so we need a context in which we can divide by $b_m$ - the coefficients are usually from a field or division ring to make this work. Here we are just dividing to get rid of the highest power of $x$.
The point is that the degree of $f_n(x)-\cfrac {a_n}{b_m}\cdot x^{n-m}g_m(x)$ is less than $n$ so we can write it as $q_n(x)g(x)+r_n(x)$ and we have $$f(x)=\left(\cfrac {a_n}{b_m}\cdot x^{n-m}+q_n(x)\right)g(x)+r_n(x)$$
As we required.
Now that is all a bit wordy and long for a simple division, but I hope it highlights the assumptions involved.