Sometimes, like in the case of 仏蘭西, these are the old spellings of the names of places before the Japanese decided to represent all non-Chinese loanwords with katanana. Other times, the ateji is used since the Chinese characters are more well-known in different countries than the hiragana and the katana, an example being that the Chinese can recognize 寿司, since both characters also exist in Chinese, rather than すし, since neither character exists in Chinese. While the Chinese characters for "coffee" is 咖啡, the Japanese 珈琲 is close enough that Chinese could figure it out with a little guesswork.