While doing ghusl my hair touched the sink while I was cleaning my legs (after I already poured water over my head) . Then I took some water and wiped the part where the hair touched the sink, then washed my legs, then I had a doubt whether I wiped it properly, so I wiped the area of the hair where it touched the sink again, but this time after cleaning my feet. Does this invalidate my ghusl?
I don't think this invalidates ghusl. There are distinct things that invalidate ghusl and you can google those. I think other punitive things such as the one you mentioned is totally fine. Remember, Islam is religion of peace, and simplicity. We always complicate matters, but always remind yourself this. :)