Red onions get their purple hue from various anthocyanins, a colorful flavonoid pigment in their cell walls (mainly cyanidin-3-O-glucoside). When exposed to the hot, acidic liquid, the low pH environment causes the anthocyanins to turn a radiant pink. This cannot be prevented. Pickle white onions instead if you prefer minimal color change.