Open the folder of 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\