Excel can not display a number with more than 15 significant digits as the number. If you are showing 18 digits then it is text. It has nothing to do with the function you're using, it is a limitation of Excel in general.
If you want to do a COUNTIF on these values, and are using a literal value, specify the number as text:
=COUNTIF(A:A,"123456789012345678")