From Bulbapedia, the community-driven Pokémon encyclopedia.
Ash's hat (Japanese: サトシのぼうし Satoshi's hat) is the most important and famous item of clothing that Ash Ketchum is seldom seen without. Throughout the Pokémon anime, Ash has worn four different hats so far, one each for the four different series. He is seen to turn his hat backwards whenever he concentrates on current situations.
Pokémon League Expo hat
Ash wearing his Pokémon League Expo hat backwards
Ash's first hat was easily the most well-known of them: an official Pokémon League Expo hat that was red and white with a green "L" on the front, which Ash claimed to have "sent in about a million postcards" in order to obtain it. Misty seems to have tried to win it too, as she stated she sent in a single postcard too. Ash wore this hat throughout all of his journey through Kanto, the Orange Archipelago, and Johto, and was very attached to it, becoming enraged when a Mankey stole it and played keep-away with it in Primeape Goes Bananas.
Commonly, Ash would turn the cap backwards, especially when he was concentrating heavily, such as when he would face a Trainer or capture a Pokémon. This was very much the case early in his journey in Kanto, though by the time his journey in Johto ended, he hardly ever turned his cap.
Advanced Generation hat
Ash's Advanced Generation hat
Ash wearing his AG hat backwards
After returning from Johto, Ash was given a change of clothes by his mother, and he immediately changed into them, including switching his old hat for a new, black and red one which had a green Poké Ball symbol on it. He seemed to have no hesitance in changing hats, despite the attraction shown in Primeape Goes Bananas. It is assumed that he left the old hat at his home in Pallet Town, where it may still be.
Like the first one, his second hat was also stolen by a monkey-like Pokémon which Ash later captured, this time an Aipom in Slaking Kong!. In a surprising display of maturity, however, Ash did not climb any trees or scream at Aipom when his hat was stolen. Instead, he actually accepted that it was gone (or so he assumed), saying that he would "feel strange" without it. It should be noted that the hat that was stolen by Aipom wasn't the same that he claimed to have sent a million postcards. At the end of the episode, Aipom returned Ash's hat to him. However, Aipom followed Ash and his friends to the Kanto Grand Festival where it stole his hat again. After Ash captured her, Aipom stole Ash's hat multiple more times as the Advanced Generation series ended and the Diamond & Pearl series began.
Ash rarely flipped his hat during the series, only doing so such as when he was dressed as an eggplant in Claydol Big and Tall or when he was cleaning the dojo in Pasta La Vista!.
He also flipped his hat in the climax of [ninth movie].
Diamond & Pearl hat
Ash wearing his DP hat backwards
Ash's Diamond & Pearl hat
Ash had received his DP hat in a package from his mother while in the Sinnoh region. Though his clothes changed quite a bit between their Advanced Generation and Diamond & Pearl iterations, his hat remained astoundingly similar, though while the AG hat had a green Poké Ball symbol, the DP one was blue. The DP hat also has more black area around the Poké Ball, being square while the black area in the AG series was oval-ish.
Ash flipped this hat just once in the whole series, in his battle against Tobias in The Semi-Final Frontier!. He did, however, do so briefly in the thirteenth Pokémon movie.
Best Wishes hat
Ash wearing his BW hat backwards
A comparison of the similarities between Ash's hat from the original series (left) to the Best Wishes series (right)
In the Best Wishes series, Ash wears a red and light blue hat. Unlike of the hats seen during the Advanced Generation and Diamond & Pearl series, this hat bears more of a resemblance to the one seen in the original series, but the front is light blue with no line running down the middle, and the logo is a blue Poké Ball design instead of a stylized "L".
During this series, Ash flips his hat more often, similar to the original series of the anime.
All of Ash's hats have been produced for people to wear. Ash's Advanced Generation hat was available to purchase at PokémonCenter.com before it shut down. His hats can be found at numerous stores (including the Pokémon Centers in Japan) and on online auction sites such as eBay.