`ack` does something smiliar to `grep`. When it puts it text to a terminal, it will spit the results out in color. If the output is redirected to a file, the matches do not get colorized.
You can override these heuristics with the options `--color` and `--nocolor`.
Check `man 1 ack` for more details.