Hmm...
Sometimes in embedded systems there is difference where strings are stored.
In the first example you define a string which is stored in flash code region only. So the comparison will fail with index 0 because of the memory area difference.
The second example you define a local variable which contain the same string. This will be located in RAM, so the comparison works since they are both in RAM.
I would test following:
char buffer[5]; //which is filled correctly later
char word[5] = "WORD";
...
test(buffer, word, 5);
Most likely it is going to work because the comparison is done in RAM totally.
Yes and remove the \0 since the "WORD" will null terminate automatically.