Two things I want to talk about:
Group by will work if the column name exists in the table you are working on. In your query, you have inner join Customer table with Invoice table. From your schema, I can see in the Invoice table CustomerId column exists.
In SQL serve have to give all the column name that you selected plus your desired column name. What I mean by that your query should be like this.
SELECT FirstName,
LastName,
City,
Email,
COUNT(I.CustomerId) AS Invoices
FROM Customers C INNER JOIN Invoices I
ON C.CustomerId = I.CustomerId
GROUP BY C.CustomerId,
LastName,
City,
Email
So, I think you are using MySQL that's why it's working.