Ventilation is achieved for the most part, in one of two different ways. Eyelet holes that offer openings for air to pass through or the use of mesh vent panels which offer breathability are both used.
These are the most common ways but sometimes you can find hats that don't have either. In this case, often times the materials themselves will be deemed breathable in nature. If your hair is long and thick, breathable materials can be limited in their effectiveness. Thinner hair, less hair, or shorter hair can increase the breathability in a material.