When I first saw the picture I thought of Wawel, but couldn't find a picture of the castle showing that particular section, so thought I was wrong. Checked again and found it, and even more embarrassing, I have a photo of it too, although not at a great angle.
It is the Hen's Foot tower ( Kurza Stopka ) of Wawel Castle.
As for what it was used for, do you mean that a part of it serves as a treasury for art of historical significance? It was also used by Michał Sędziwój, an alchemist and doctor, as a science laboratory.