My knees and ankles are hurting due to flat feet, overpronation and old injuries. Is there a way to treat all of these conditions?

Sure. Seek out a sports podiatrist who can explain to you a treatment plan to strengthen your entire kinetic chain.
Orthotics. You need rigid orthotics to contol your overpronation or possibly even a type of foot/anled brace.