Actual RSA implementations do not attempt to avoid cases where the ciphertext and $N$ are not coprime. They don't need to. And in some sense instead, they make sure $N$ is the product of distinct primes.
Maybe you have been given a proof that textbook RSA correctly decrypts under the hypothesis that the message is in $\mathbb Z_N^*$, that is an integer in $[0,N)$ and coprime to $N$, which is equivalent to the ciphertext being in $\mathbb Z_N^*$. However it turns out that a different proof can be made that instead uses the hypothesis that $N$ is the product of distinct primes, and allows as message and ciphertext any integer in $[0,N)$. That's the practice.
Also, in practice, $N$ is so large that a vanishingly small fraction of $X$ in $[0,N)$ are not coprime to $N$. When $N=p\,q$ with $p$ and $q$ distinct primes, there are only $p+q-1$ such $X$, that is a proportion roughly $2/\sqrt N$ when $p$ and $q$ are of comparable size. Thus stepping on such exceptional $X$ can not happen accidentally, or by trying at random.
Further, since the factorization of $N$ is secret, $0$ is the only such $X$ that adversaries can manage to find. Argument: if they could find any $X\in(0,N)$ not coprime to $N$, they could efficiently compute a non-trivial divisor of $N$ as $\gcd(X,N)$, and thus break RSA when $N$ is the product of two primes, or make it much easier to factor $N$ otherwise. Since $N$ is (by hypothesis) chosen such that it's hard to factor (even in part), finding such $X$ must be hard.