Match whole words only
Match whole words only with grep -w. A match must sit between non-word characters, and letters, digits and the _ character all count as word characters.
Searching for cat also finds concat and category, and you want only the lines that hold the word on its own.
printf 'cat\nconcat\ncat-food\ncat_food\nthe cat sat\n' | grep -w catcat
cat-food
the cat satWith -w grep accepts a match only if the character before it and the character after it are not word constituents, which are letters, digits and _, as the GNU grep manual describes. That is why cat-food matches and cat_food does not. Grep also tries again at a later position in the same line when the first match fails the test, so a line can still match.
The check is about the edges of the match, so it does not help with a pattern that itself contains a space or punctuation. For custom word boundaries use grep -P '(?<![A-Za-z])cat(?![A-Za-z])' with GNU grep built with PCRE. BSD grep accepts -w too.