anytime your body goes through something stressful, surgery, extreme sickness, pregnancy, even periods of extremely high stress your body takes the nutrients its not getting from your hair and your nails, so when your hair goes through its growth cycles, the cycle where it should have been growing to replace the new hair can be affected by that, and then it also has damaged the hair thats already there, so you will lose hair and not grow as much back at the same time.
Your nails may show pits or lines totally random, but historians can look at the nails of a someone who was mummfied or perseved with their nails intact and see evidence of illness or injury, yeah i know ya'll dont care, just some of my useless knowledge.
Anyway, its normal that your hair is falling out, esp if you were on certain meds also. Some vitamins can help, but mainly its just time.
By the time i had surgery i was down to about 1/3 the amount of hair i had before i got sick, luckily i have thick hair so it wasnt that bad. Now, 2 years post surgery i am up to about 3/4 and its still growing thicker.
I know how scary it is, but it will stop and it will grow back, its just slow.