The teething itself doesn't cause the diarrhea but there is a link between your baby teething and diarrhea.
When your baby is teething they drool excessively and that excessive drool or saliva gets into your babies gut which then makes it's way to the babies bowels and stool.
So the drool from the teething causes your baby to have diarrhea and sometimes a diaper rash due to the change in the consistency of the poop.