With GROUP BY, each group gets its own distinct-value buckets.
per group buckets
Read grouped output
The compiler forms 3 groups and outputs 3 count rows.
groups=3
COUNT DISTINCT examples are tiny finite-table transforms; SQL dialect completeness, collations, type coercion, optimizer behavior, execution cost, indexing, and database-product claims are out of scope.
Groups do not share buckets
A value repeated inside one group does not affect another group's count.
separate group buckets
Summary
Grouping happens before each group's distinct count.