Question: In this case, either "se quitaron el sombrero" or "se quitaron los sombreros" could be used, although the former is probably more typical and would often be preferred.
In Spanish, it is very common to use the singular in sentences such as the following where each person has only one of the object in question:
- Se quitaron el sombrero. They took off their hats.
- Todos los hombres tienen esposa. All the men have wives.
- Les detuvieron a tres con barba negra. They arrested three men with black beards.
- Todos estudiantes deben tener un coche. Each student should have a car.
- Les cortaron la cabeza. They chopped off their heads.
One way of thinking about such sentences is to view "quitarse el sombrero" as a fixed phrase meaning "to take off one's hat" or "tener esposo/esposa" as a fixed phrase meaning "to be married."
Sometimes the use of the singular in similar sentences can help remove ambiguity. For example, se quitaron el zapato makes it clear that each person removed one shoe; se quitaron los zapatos might suggest the people removed both shoes.

