Sure you can, for example, change your Toxapex into a Steel-type to give your team a way to handle Tapu Lele... but what do you do if you change the only thing on your team that does well vs something like Volcarona that now actually threatens Pex? Or deal with the fact that now Magnezone can trap and KO it?
Terastallize based on team preview.
If your opponent has Tapu Lele, Terastallize.
If your opponent has Volcarona, don’t Terastallize.
If your opponent has both, maybe build a better team or Terastallize something else to check either Pokemon.
I think your analogy just proves its usefulness, as Toxapex had no chance to check Tapu Lele, and if your opponent is running Tapu Lele and Volcarona, your Toxapex still has to deal with Volcarona.
Meanwhile, most (Purely) offensive uses of Terastallization don’t significantly change a Pokemon’s match-ups besides Tera Blast.
Like for example, let’s pretend Electric or Fire are bad defensive typings, and you Terastallize Victini.
With Fire, your V-creates are a lot more powerful, but most of your checks are still going to check you because your Fire typing doesn’t change what it is Super Effective against.
With Electric, your Bolt Strike is stronger, but it’s not like Water types aren’t already beaten by Bolt Strike anyways.
That isn’t to say using it offensively is bad by any means, or that defensively Terastallizing makes you unkillable. It’s more that you can expand each defensive Pokemon’s good match-ups, while offensive Pokemon aren’t going to change most of their match-ups without Tera Blast. Like Volcarona can use Ground (which is useful defensively) and Tera Blast to beat Toxapex and Heatran, but that doesn’t mean much if Volcarona learns Earthpower naturally in SV.