I think this is a Unicode problem rather than an Emacs one. I tried your code out in the scratch buffer and it seemed to work fine.
I can't say for sure without looking at your text, but the problem may be that your "ā" characters aren't actually "ā" (U+0101). Instead, I suspect that they may instead be a combining character sequence of ("a" and the combining character ̄ (U+304)), the result of which is an identical but different "ā". (You can see the difference by copying and pasting each of "ā" and "ā" and then trying to backspace over them.) If this is the case, search forward won't match because this combined character is distinct from "ā".
The following function should remove the combining character, leaving behind just "a" in each case.
(defun nv/eliminatemacron2 ()
(while (search-forward "ā" nil t)
You could also just generally replace all of the combining macrons with the empty string to get rid of this kind of sequence (
(replace-string "̄" "")). Note that the combining character tries to combine with the double quote which doesn't display properly on Stack Exchange, but it appears to copy and paste properly for me. On Emacs it should appear that the starting quote has a macron, but really the macron character comes afterwards. If this doesn't work, you can manually type the character in with
C-x 8 RET COMBINING MACRON.