@steevej and @Ronan_Merrick have both provided useful answers, so I won’t repeat anything they’ve said. I just wanted to drop in a maybe helpful suggestion that you check out the high-level documentation on the aggregation framework.
Conceptually a call to aggregate starts with all the documents in a collection, and then passes them through a series of aggregation stages which will do things like filter out documents (with $match for example), modify them (with stages like $project and $lookup or transform them into something else (with stages like $group). The documents output from each stage are passed to the next stage for more modification, until the end of the pipeline, where whatever documents are emitted from the final stage are then provided back to the client.
That’s why the stages are provided as a list - it’s a sequence of operations to be applied to the documents. It’s also why you need to do a $match to filter the documents that match your WHERE criteria, before doing a $group on the documents that remain, to get the average applied to all the documents, as @Ronan_Merrick suggested.