Taking metformin till I’m 12 weeks

How does metformin reduce miscarriage?