Shikaree is partly right and partly wrong. Here's a link to an Ask the Devs post (link in text).

It's supposed to be a high risk/high reward thing. From lowest risk/lowest reward to highest risk/highest reward, it goes: White --> Yellow --> Red.

When it's flashing different colors, it can be any of the three colors. But it can't be any more high risk than red.

If you've got enough durability left, you can "wait" when the element is unstable. Sometimes I'll "wait" when it's Red to give me a better chance of success.