This is what I was thinking the whole time. Rome was surrounded by peer competitors, and OP says their most effective use of elephants was against non-peer competitors like Spain or Gaul.
So why would competitors continue to use elephants? Not because Roma was susceptible, but because THEIR boarder competitors were susceptible.
Elephants were not worth it to defeat well-trained troops, but were more than worth it to defeat smaller, less disciplined armies/militias.
My guess is that Rome's peers were often using elephants to keep smaller competitors in check, and only used them against Rome because they happen to have them anyway.