Chemical pregnancy...??

Hello ladies I'm looking for advice on a chemical pregnancy I have had at least 4 cycles within the last year and half that was clearly positive but it would quickly fade away and turn negative I have taken my hpt to the doctors and they confirmed it was indeed positive proceeded to test at the clinic and boom negative I feel like I can't even get excited anymore if I see a positive because it gets taken away so quickly the doctors never mentioned anything to me about a chemical pregnancy they just told me my test was negative and then that was the end of it which left me with a million and one unanswered questions because I don't know if it was a faulty test or a chemical I guess my question is how can u prevent chemicals in the future the only known issue I have is hypothyroidism which is now under control