Using non- related subqueries

https://www.codecademy.com/courses/sql-table-transformation/lessons/subqueries/exercises/non-correlated-iii?action=resume_content_item

Hi. I have a question about using non- related subqueries.

In the given exercise, the given proper solution is

SELECT a.dep_month,
a.dep_day_of_week,
AVG(a.flight_distance) AS average_distance
FROM (
SELECT dep_month,
dep_day_of_week,
dep_date,
sum(distance) AS flight_distance
FROM flights
GROUP BY 1,2,3
) a
GROUP BY 1,2
ORDER BY 1,2;

But as I was coding, I sprung up with the idea that the whole subquery was unnecessary, so I wrote my own code without the subquery as below.

SELECT dep_month,
dep_day_of_week,
AVG(SUM(flight_distance)) AS average_distance
FROM flight_distance
GROUP BY 1, 2;

but the query did not work at all.
I don’t see the difference between the two and super confused
somebody help me