As someone who played Sims 4 before Sims 3, I'm not too fond that hats determine hair style. 4 had hats as their own category. But I've seen custom content make hats that count as accessories and not affect hair style. Either someone give me advice on how to convert the hats into accessories, or for someone to do it for me. I prefer the latter, but am okay with the former.
First, you need to understand the basic method of meshing; how to separate the hat mesh from hair in meshing program (Milkshape or Blender), delete the hair,
then convert the hat mesh to accessories using CTU or TSRW.
Better you ask creating-related discussion on Sims 3 Creation "CAS part" link HERE for more details. Because this section is for discussing general Sims-related, not creating custom content, so not everybody here can help you.