A sudden change in diet can cause digestive upset, which can lead to vomiting, diarrhoea, and other problems. Additionally, if your dog is allergic to a particular ingredient, changing their food too quickly may not give their immune system time to adjust, and symptoms may actually worsen.
For this reason, it's best to transition your dog to a new food gradually over a period of several days. Start by mixing a small amount of the new food with their old food, and gradually increase the amount of new food over time until they're eating it exclusively.
If you notice any signs of digestive upset, slow down the transition process or stop it altogether and consult with your veterinarian.