Some mechanisms of action are just simpler than others. The anti-helminthic action of ivermectin is pretty straightforward: it activates a class of nematode-specific glutamate-gated chloride channels that result in paralysis (but only in nematodes). The anti-viral part is also not too confusing: it binds to and inhibits a protein that is important for import of (some) viral proteins into the cell nucleus--so it is actually acting on you, but since these import facilitating proteins aren't all that essential for regular cellular function, it's tolerated pretty well. (The doses used against nematodes are generally too low to have much effect on viruses.)
But the mechanism of action of metformin has not revealed itself so easily. It's known to affect AMPK, which is involved in regulation of metabolism (including but not limited to glucose metabolism), but it doesn't show any binding activity to AMPK...so...huh. And then there are other effects of metformin that seem independent of AMPK and...we...haven't found what it binds to to make that happen either.
That's biology for you. Not everything is equally easy to figure out. Sometimes the answer leaps out at you (given appropriate experiments), sometimes it's a slog.