Anything that compromises your snake's immune system can lead to it. Basically as far as I understand it, most RIs in snakes are bacterial infections, and as you well know there is bacteria everywhere. Not all of it is bad of course, but if you have a compromised immune system, you're less able to fight off the ones that can infect you.
Additionally housing that is bacteria laden (warm and too wet, or simply unclean) can lead to RIs.