I haven't figured it out yet either, but it definitely shows up more in potted plants. When I grow a plant outdoors directly in the ground, they don't get red stems, not even in late flower when temps drop below 50f. When I grow cuttings of those same green plants indoors, the red stems show up no matter what I do, especially on the plants that have purple flowers.
I suspect it has something to do with the growing medium. Almost every potting mix has peat moss, which acidifies the soil and locks out calcium and magnesium.
Ive noticed that increasing potassium helps but it doesn't completely stop the red stems.