Another technicality, Terra didn’t so much turn bad as she did stop acting good. However, she kept up appearances so well that it was a huge shock to both her teammates and the readers, it definitely felt like it was a hero turning into a villain rather than revealing her true nature.
While working with Robin, Kid Flash and Red Arrow, Terra looked to be firmly on the good guys’ side. However, it was discovered during The Judas Contract storyline that she was constantly sending information to Deathstroke the Terminator, including the team's true identities, which eventually leads to Deathstroke picking them off one by one.
The Judas Contact also ties together several unrelated arcs in Teen Titans that showed Terra had been secretly sabotaging them all along. Co-creator George Perez apparently always intended her to be a mole, but because she appeared to be fighting the good fight for so long, it was a complete shock when the mask finally slipped.
Robin, at least, was able to get away from Deathstroke and ultimately become Nightwing, but Terra’s betrayal still rocked the Teen Titans to their core.