Try this:
=COUNT(IF(L7:L10="a";ROW(L7:L10)))
Thid doesn't depend of second column. It just calculate number of a in first column.
Your approach might give you different results depending of data in M column
Problem with first formula is because it counts zero's in product as numbers.
Evaluate formula:
=COUNT((L7:L10="a")*(M7:M10))
=COUNT(({TRUE;FALSE;TRUE;FALSE}*(M7:M10))
=COUNT(({TRUE;FALSE;TRUE;FALSE}*{1;2;3;4})
=COUNT({1;0;3;0})
=4
while second formula give this:
=COUNT(IF(L7:L10="a";M7:M10))
=COUNT(IF({TRUE;FALSE;TRUE;FALSE};M7:M10))
=COUNT({1;FALSE;3;FALSE})
=2
Bookmarks