As others have said, HT (or rather, low/no testosterone) is known to cause many issues in the body. The duration for which it's taken is about balancing those increasing risks with the benefits of a higher chance of cure, where the incremental benefit reduces with time.
Some risks are:
Osteoporosis, diabetes, metabolic syndrome, high cholesterol, raised blood pressure, cardio vascular disease, gynecomastia, damage to penile structures, ...
For those on lifelong HT where such a trade-off can't be used, the HT does cause the death of some of the patients, rather than the PCa, but without it, their life would have been shorter still.
Some patients with a particularly high risk of cardio vascular events are given Degarelix instead of the other HT drugs, because it is claimed to have a slightly lower impact on cardio vascular events.
No treatments are without risk, but considerable thought is given to balancing the risks and benefits of all the treatments.