Why do I keep getting breast infections?

Tough to say. Your answer may come best by the dr. Who is treating you for them. Sometimes, there can be underlying areas where infections are lingering and they may cause periodic flare-ups. Check with your treating dr., and see what they feel is the cause. Best wishes.
Correct technique. Proper "latching" and the use of protective products like lanolin on your nipples to prevent cracking is good advice. Also i believe a lot of breast infections are actually blocked ducts which cause painful, sometimes red lumps in the breasts. In this case and with infections, feeding should continue and is safe.