Your whole code is wrong period. There is no “because”.
Distance is a measure. In float.
The input you are using is a float 3.
The result would mean some sort of difference between RGB of A and RGB of B.
As a float 3.
Probably euqal to B minus A as RGB.
Ei: blue minus blue equal 0 blue channel.
Again, completely useless.
What you are asking for above, is only applicable by your own asking to a single channel. BLUE. So work in a single channel - which also costs less.
Further, switch makes no sense, as it takes the values and toggles them on or off based on something. But in theory an IF would already be doing the same thing. Either filtering out, or returning the same.
Additionally, you don’t multiply colors to change them. 0x1 is? 1x1 is? Your result of 0,0,1 x 0,0,0 would be?
Just no.
To color something a different hue, you use a lerp and replace light to black values to other color(s).
You can change single channel darkenss/lightness to create a different specific color, or you can do it on a texture as a whole by feeding a desaturated version of it as the alpha.
Essentially, go back to the drawing board here. Potentially to learning how materials work.
I would suggest any Ben Cloward videos on youtube as an introductory start.
Also some of the Escape Studios videos - though not as basic - are probably a good idea.