When a virus infects a bacterium, fragments of the viral DNA are integrated into the CRISPR array. If the same virus attacks again, the bacterium can produce RNA sequences from these DNA fragments that guide Cas proteins to the viral DNA, enabling them to cut and inactivate it. This process is highly specific, allowing for targeted destruction of viral invaders.