This is not some magic behavior of pipelines. Rather, less (like many other terminal programs) is explicitly programmed to behave differently if the output is a terminal. Specifically, the less source code has this comment in it:
"/*
* Output is not a tty.
* Just copy the input file(s) to output.
*/"
grep does this to, which is why the color-coding control characters don't mess up other commands.
"I want to look through this file..."
"Oh, that's long, I want to look at all the foos..." "How many foos are there?" Try it, it works!