Why it is used es instead of eres in the sentence "¿Cuál es tu sombrero?"
The question means "Which is your hat?". It uses 3rd person because the hat is an object. 'Eres' means 'you are'. If 'eres' was used, the question would say something along the lines of "Which you are your hat?"
Because 'eres' is the 2nd person singular ("you"). The subject in this case is the hat, which is 3rd person singular 'es' ("he/she/it"). You don't refer to a hat as "you", you would use "it".