Count every occurrence not just lines
Count every occurrence of a word with grep -o piped to wc -l, because grep -c counts the lines that match and a line with three hits counts as one.
A word appears several times on some lines, and the count you need is the number of times it appears, not the number of lines it appears on.
printf 'to be or not to be\nbe\nmaybe\n' > lines.txt
grep -c be lines.txt
grep -o be lines.txt | wc -l
grep -ow be lines.txt | wc -l3
4
3-o prints each non-empty match on a line of its own, so wc -l counts matches rather than lines. The documented behaviour is in the GNU grep manual. The third command adds -w, which keeps whole words only, so the "be" inside "maybe" no longer counts: 4 hits become 3. Use -w whenever a short word can sit inside a longer one.
Matches cannot overlap, so counting "aa" in "aaa" gives 1, not 2. The pipeline also reads the whole input and prints every match first, which is slow for a very large file with millions of hits. In that case let awk count with gsub instead.