On 10 February 1840, Queen Victoria married Albert of Saxe-Coburg and Gotha. While Victoria was descended from the related line of Saxe-Coburg-Saalfeld, in the UK she was the last of the House of Hanover. Their son Edward founded the House of Saxe-Coburg and Gotha, changed to the House of Windsor in the Great War.
While it is correct to attribute the late 1917 change to anti-German sentiment, a prompt was the name of the night bomber terrorizing London from earlier that year. The monarch of the time was Edward’s son George V, last surname Gotha and it was too much to have one’s subjects being killed with bombs from a plane known as Gotha G.IV.