Ants specifically target fatally infected colony members thereby preventing infections from spreading through the colony. This is achieved by removal of infected brood from the nest and treatment of the infection in the host, e.g. by injecting antimicrobial poison, stopping pathogen replication.
Read more on how ants detect and remove infected larvae from the brood pile and perform destructive disinfection of fatally infected pupae:
Ugelvig et al 2010 Proc B
Pull et al 2018 eLife