Mutations can occur through various mechanisms. Spontaneous mutations happen due to errors in DNA replication. Induced mutations can result from exposure to environmental factors like radiation or chemicals. Genetic recombination and horizontal gene transfer are other ways through which pathogens can acquire new genetic material, leading to mutations.