Choose the hat you wnt to replace and extract the models and materials folders to your \team fortress 2\tf\ folder, usually located in

C:\Program Files\Steam\steamapps\yoursteamusername\team fortress 2\tf\




Also, replace a hat that doesn't fall of the head when dying or the hair will do so.