The last image is not even an "exclave" ...it's Albarracín and its "cheese holes" :) -by the way, Albarracín is a very beautiful place, I recommend it if you ever travel here-.
I think the reason is to preserve the historical access of the capital of the county to all its municipalities. But it's like that!