Second of all, how does that even work? Metformin is very very widely prescribed.
There are many different ways to patent a drug. Composition patents, formulation patents, use patents, etc.
The problem is that if you get a "use" patent, it only stops other company from promoting the drug for the use you patented. In the case of metformin, it's already available as a cheap generic.
So if a company were to conduct studies proving that it reduced the risk of cancer and got a patent on it, there is nothing to stop a doctor from prescribing the generic version.
So unless a company can find a way to recoup their R&D costs associated with running the trials, they won't bother.
The doctor? He doesn't really make a profit of this and at least over here in Austria, a doctor may prescribe any substance he wants as long as he can argue that it is for the well-being of his patient.
The producer of the diabetes drugs? They don't sell it as a cancer drug.
The apothecary? He's just following the doctor's orders.
That's why you rarely (never?) see a drug company take an old, off-patent drug and try and get a patent for it (in it's original form) on a new disease. Since there is no way to recoup any investment costs, they simply don't make the investment.
What does happen is that drug companies will take an old, off-patent drug and modify it somehow so that it can be patented. They can do that a number of different ways: create a unique formulation of the drug, create a drug-device combination product or try and create a slightly modified (and hopefully improved) version of the original drug.
Under the current system, unless you have a patent (or marketing exclusivity from the FDA) you have no opportunity to recoup any investment you made in the drug.
I'm not 100% sure of this, but I'm pretty sure that this is the way the FDA approval process for drugs work. You can't just 'decide' to prescribe Metformin for cancer one day.
A single drug has to go through the approval process N separate times for N separate applications/diseases.