how can a harmless bacterium suddenly become capable of producing a dangerous toxin?

A harmless bacterium can become capable of producing a dangerous toxin through a process called horizontal gene transfer. This can occur when the bacterium acquires a plasmid or a piece of genetic material from another bacterium that contains the gene for producing the toxin. Alternatively, the bacterium may undergo a mutation that causes it to produce a dangerous toxin. This mutation can occur spontaneously or due to exposure to certain environmental factors such as antibiotics or toxins. Once the bacterium has acquired the gene or undergone the mutation, it can start producing the dangerous toxin, leading to harmful effects on the host organism or environment.