If you haven't been converted yet, you're fine. Just kill any apostles or missionaries that come close (you'll have to declare war and use military units). Make sure you don't conquer too much and accidentally acquire a preponderance of cities in the wrong religion. You might need to raze cities to avoid this. (Did I mention Religious Victory is super dumb?)
If the Civ in question has already converted you, it's tougher. Part of the problem here is that not only will the Civ who founded the dominant religion spread it around, but all the AIs it has converted will
also produce religious units and spread that religion (even though doing so loses them the game!) So even declaring war on and killing the religious Civ may not be enough, though it can't hurt. Your best bet is probably to figure out which Civ has not been converted yet (use the Religious Victory tab), station some military units around its borders, and kill any religious units that try to enter.
In future games, you can just preemptively slaughter any religious units that come your way from the start. Do that and you will never lose to Religious Victory.
Also--never give up! I had one Deity game where England had a carpet of about 20 apostles and needed to convert literally
one Brazilian city to win Religious Victory. I couldn't possibly get units there in time to stop it, so I didn't even try. Much to my surprise, though, England never bothered. About 50 turns later I won a Cultural Victory. So with this AI, there's always hope
