Bacteria can change its DNA in reproduction or transfer various different genes to build resistance. Viruses can do the same. Both will naturally change and improve over time because the DNA is always changing.The bacteria can also mutate to better help it in its environment.