If there is, in fantasy fiction, a wizard living somewhere, you can count on him to live in a tower. Often these towers have smaller towers attatched to them, usually about halfway up the main tower. Did this type of tower exist in history? In case it did, what was the purpose of these smaller towers?
They weren't really a thing of any period. The closest we get is the ornate post-Medieval architecture, in particular French Renaissance of the 16th - 17th century.
Since the 19th century these styles have become merged in the western imagination, producing such modern, pseudo-medieval 'wedding cake' castles like Neuschwanstein. Not unlike how the 19th century produced a lot of fantastic, exaggerated imagery of the medieval period.
There were rarely towers attached to towers' side, but towers on top of towers, to create another layer of defence was if not common, at least not unheard of.
Conwy Castle in Wales have an example of this.
Yes, such structures exist, but are smaller (about the size of that corner turret, a "bartizan") * - otherwise they wouldn't stay there long. Their main purpose is to help defense by providing a safe way to watch and shoot at attackers that reached the wall, they can be used to drop/pour something on the enemy ("bretèche"), cost less than real side towers, and allow convenient, "self-cleaning" toilets ("garderobe").
edit: * and less overhanging