Before the letter U existed the letter V served as both letters. The letter W was literally double U’s.
The alphabet we use today, with 26 letters, is descendant from the Latin/Roman alphabet (the alphabet ancient Romans used to write Latin) which had 23 letters. The letter U wasn’t a part of the original Latin alphabet but that’s not to say that the U sound didn’t exist. The V letter form did double duty in the Latin alphabet, serving as both the consonant V sound and the vowel U sound. A reader knew which sound to make from the context of what word the letter was in (just like how many of our letters are read today).
The first recorded separation of U and V took place in 1386 in the Gothic alphabet. Initially U was just a different shape for the letter V (similar to how the letter J started off as a different way to write the letter I). The U and V shapes were used interchangeably but a rule formed to use the V shape when it was at the beginning of a word and to use the curved U shape if it was in the middle or end of a word (regardless of the intended letter sound). It wasn’t until the 17th century that the letter U became the letter we think of today, assisted in 1629 by printer Lazare Zetzner who made a clear distinction between the V shape and the U shape.
Today, despite the letters V and U having been separate letters for several centuries, we still see relatively modern buildings that feature the sharp V shape in place of the letter U. These are typically buildings in the classic Roman architectural style (city halls, courthouses, etc.) that have chosen to engrave their Us as Vs as a stylistic nod to the Latin alphabet and ancient Rome.
Like the letter U, the letter W was also not a part of the original Latin alphabet. Over in England the Old English alphabet, in use from the 8th to the 12th centuries and was descendant from the Latin alphabet, also did not have the letter W. Unlike the Latin alphabet though (and confusingly) the Old English alphabet did have the letter U but not V.
So when it came time to write the W sound, the English initially used two U’s sitting beside one another (looking very much like our modern W shape). Then in the 8th century they switched to using the rune Wynn (ƿ) to represent this sound, but around 1300 they changed their minds and went back to writing it as UU. The clue being in the name, this is why the letter is called “double U.” The name “double U” continued even as the visual design of the letter became more like two V’s placed together.
As typefaces were created for the printing press, some began to create a letter form for W. For the typefaces that did not have this letter, printers continued to place two U’s beside one another. Today the letter W is its own letter and not double U’s.
Added info: while the Latin alphabet is the basis for many western writing systems, not all languages use the letters the same way. In English the letter W is pronounced like “wuh” but in German the letter W is pronounced more like a V, which makes the name Wolfgang more like “Volfgang”. In Welsh the letter W is a vowel.
Also, from 1928 until 2013 it was illegal to use the letter W in Turkey (as well as the letters Q and X). This was part of a policy by the Turkish government to force its people to speak Turkish and to make it difficult to write in other languages.