The problem with color by expression is that you could give any segment any color. So Qlik Sense can't be sure that you're giving each dimension value a color. The expression could give every combination of dimension value and some other value a unique color. So Qlik Sense can't show a color legend for the dimension values.
If you want to use custom colors for your dimension values then you can create a master item for that dimension. That master item is where you can then give each dimension value its own color.