Sometime between 1986 and 1987, I watched the final scenes of a show:
A misshapen, hunchbacked fellow was doing a main-bad-guy final-act routine in front of a group of kids who I assumed were the heroes and several dragon heads shot out on long necks from his hump. He was about to win, when a new character appeared out of nowhere (I seem to remember he had been a dragon before, apparently a nice one.)
The evil sorcerer's eyes widened in puzzlement and he asked the other one how come he was here. The new character, a bespectacled, apparently rather nice fellow, explained that it had suddenly occurred to him that two persons could not exist in the same place — and so there he was.
As the evil one called forces of magic to his aid, the bespectacled guy called upon physics, geometry, logic, mathematics (each by name) or other scientific disciplines. Each time he named one, a dragon head from the bad guy's hump popped out of existence and the evil sorcerer shrank. After invoking a number of scientific names, the bad guy was defeated. I think the victor, after a chat with his friends, returned to his home world (very similar to our own) and that was that.
I got a definite Dungeons & Dragons (the TV animated series) vibe from it, but that may just have been me making connections and assuming from similarities (fantasy world, kid heroes, maybe someone from banal Earth who is transported to the fantasy world, and I think it looked more like western animation than Japanese, but I might be wrong on that).