where clauses are applied at the row level, literally a "should this row be included in the result set". At the time that decision is being made, it's impossible for the count() function to have finished its work, as not all rows have been counted yet.
That's where having clauses come in to play. They're exactly like where clauses, but applied immediately before the result set gets sent to the client, after the aggregate functions have completed their work.
Technically, doing
SELECT * FROM table HAVING somefield='a'
SELECT * FROM table WHERE somefield='a'
are identical, except the having clause will entail a bit more work on the part of the server because all the rows are fetched, THEN filtered, rather than being filtered before fetching.