Open the folder of the class you want a hat for, then the hat you want to replace, then extract the materials and models folders into your team fortress 2/tf/ folder, usually located in

C:\Program Files\Steam\steamapps\your steam username here\team fortress 2\tf\

I suggest replacing a hat that doesn't fall of on death or something magical but not very wonderful might happen