Metformin is one of the biguanides. When I search "biguanides mechanism of action" I get a number of results, all start with "not fully understood". If I search for metformin, I get blocks glucose absorption in the SI, reduces glucose production in the liver, reduces insulin resistance. Those are all what it does systemically - not how it works.
Odd that more is known about how ivermectin (a primarily veterinary drug) works than metformin (millions of people using it over decades - centuries if you count French lily).