ls assigned colors because it was configured to do so, either by you or your distribution.
> plus, it's unusable in a script, because then "ls" suppresses the color.
ls doesn't do anything different in a script, you probably just have an ls alias. Aliased are typically not sourced for non interactive shells