It happens when germs infect the joint. This can be from bacteria, viruses, or fungi. The germs enter through the blood or directly, like from an injury.