is (a/b)%m equal to {(a%m)/(b%m)}%m ? (i.e. before doing modular inverse, find mod of both numerator and denominator)

I knew (a/b)%m is {a%m * (b^(m-2))%m}%m

But in this program for finding nth catalan number, the author found (2n)! mod m , n! mod m and (n+1)! mod m and then used the modular inverse to find the result.

Is the approach wrong but got AC because of bad test case or the approach is correct? If it is correct, can anyone point out why?