I'm just taking a guess but:
The color of the shampoo is changed by dyes, the part of the shampoo that lathers is still the same stuff. I doubt that the chemical that lathers goes through a chemical change and actually changes color, but rather the mixture of lavender dye and latherchemical causes it to appear purplish. So when you lather up, the dye stays on your scalp but the lather lathers.
Complete guess, but it sounds reasonable to me.