why the color word is used in this way: "dark" chocolate and "black" coffee

Solution 1:

"Dark chocolate" is a marketing term for what used to be marketed as "plain chocolate". "Plain chocolate" is the older term but "dark chocolate" has become more popular. (I added the words "bar of" in an attempt to exclude false positives where the phrase "dark chocolate" is part of the description of something by its colour.)

Plain chocolate is so called to distinguish it from milk chocolate: no milk is added in making it. "Dark" patently refers to its colour. As for why the word "dark" is used to denote such chocolate by its colour: what other word would be better? The whole term must distinguish it from milk chocolate, and both products are brown.