Count the matches per file
Count the matching lines in each file with grep -c. With several files grep prefixes each count with the name, and -h removes the prefix for one total.
You want a count of how many lines match in every file of a directory, not the lines themselves.
mkdir demo && cd demo
printf 'error\nok\nerror\n' > a.log
printf 'ok\nok\n' > b.log
printf 'error\n' > c.log
grep -c error *.log
echo ---
grep -c error *.log | awk -F: '{ sum += $2 } END { print sum }'a.log:2
b.log:0
c.log:1
---
3-c suppresses the normal output and prints how many selected lines each file holds, with the file name in front when there is more than one file. A file with no match is listed with a count of zero, which -l would leave out. The option is described in the grep manual. Sending it through awk adds the counts into a single total.
The number is lines, not matches, so a line with three hits counts once. The count of every occurrence is in count every occurrence with grep -o. When the input is a single stream on standard input, there is no file name and the output is just the number.