It's because being waterlogged allows for the growth of anaerobic bacteria. Setting up a bioactive substrate can sometimes help with it. Using a mix instead of a singular material can also help sometimes.
Yeah, I can't do bugs, lol. But I've been thinking next time it's due for a change I'm going to mix in a little soil and orchid bark.