I found out one can get it from injury (when it kills body tissue), but what exactly does an infection do to cause gangrene, what do you recommend?
Treat the infection. Infection can cause swelling and decreased blood circulation to an area and cause tissue necrosis. Management of infection, includes local care, identifying cause of infection and then treatment with culture specific antibiotics. See your pcp for diagnosis and treatment.
Blood supply. Infection can cause and interruption of blood flow by causing inflammation and edema of blood vessels, leading to loss of blood flow. If this is extensive or does not resolve quickly, ischemia and gangrene can occur.