I could have written your post in my first pregnancy (I'm marginally better in this one). I'm not exaggerating when I say I used to think about what my baby's funeral would be like and how we would cope. I wouldn't buy anything, any gifts went straight to MILs, didn't get a pram until I was about 35 weeks and refused to even pack a hospital bag (which was nonsensical because I would still need a hospital bag if the worst happened, plus when I did go into labour DH had to try and pack it for me which was a shambles).
The trigger for me was that a close friend had a full-term stillbirth a few years ago. She has told me how naive she was and how she never even considered not bringing her baby home alive and healthy. The whole thing made me go too far the other way in that i couldn't even contemplate that I would get to bring a baby home. I was obsessed with googling statistics about stillbirth and other things that could go wrong. I was a nightmare to live with so much that DH threatened to cut off the wifi!
I think for me, it is just part of my personality. I'm not a negative person (to be around) but I do tend to consider all the possible worst-case scenarios in a situtaion and almost make myself plan how I will feel about them and cope with them if those situations arise. Google 'defensive' or 'protective' pessimism if you think you might do this too - it made me realise that this is an 'actual' thing, rather than me just being crazy.
My baby was fine. He was and is absolutely perfect and I am so grateful. I am now 36 weeks pregnant with DC#2 and have handled this pregnancy better overall, but the old fears are coming back now I am near the finish line. My friend was 12 days overdue when her baby died and I am petrified of going over with this one (DS was two weeks early, thank god). I spend ages looking up stats of whether one early baby means the next one will be etc...
I have no advice really as you can tell, but you are not alone. Pregnancy can be a very long and lonely 40 weeks and if you are prone to anxiety or it gets triggered by something then it can be very hard to shift. My one consolation is that my anxiety disappeared as soon as my baby was born - I'm not an anxious mother and lots of people tell me I'm really laid back and easygoing as a parent. I hope the same happens for you.