This is what is known as "tren cough". It can happen with tren as well as other injectable steroids, though tren is the most popular. No one is certain what the cause is, but many people believe it is related to the solvents. Tren is heavier than some other hormones and thus can require more solvents to keep it stable. Some people, myself included, believe that the body is atttemping to expel them through the lungs. For some people, this issue is worse than others. There is no way to ensure that it will not hapen in the future, but you can take precautions. I found that if you mix your tren with other, easy to use steroids, like test e, it is less likely to cause a problem. Make sure that the oil is mixed well in the barrel before injecting. Then when you inject, do so very slowly. If you notice the metalilic taste, stop right away. Pull out, put a new needle on and ideally, start back up with fresh pin. You can try to same site again or you can use a new site.
FYI, Tren cough can be really nasty. It sounds like you have not gotten a full experience of tren caugh. If you do ever get it bad, stay calm and remember that it will pass. Try to keep breathing and wait it out. The worst should be over in a min or two