Off Platform Project: The Best Of Baseball Awards - question about the code used for 'biggest spenders'

Link to the offline project I’m referring to is: https://www.codecademy.com/paths/design-databases-with-postgresql/tracks/what-can-i-do-with-a-database/modules/querying-baseball-data-off-platform-project/informationals/off-platform-project-baseball-through-the-years

I was working on the big spender task and originally I used the below code:

SELECT 
	SUM(salary), 
  teams.name, 
  salaries.yearid
	FROM salaries
LEFT JOIN teams
	ON teams.teamid = salaries.teamid
GROUP BY 
	teams.name, 
  salaries.yearid
ORDER BY 
SUM(salary)
DESC;

This code seemed to work fine but when I checked the solutions file their code was:

SELECT 
	SUM(salary), 
	teams.name, 
	salaries.yearid 
FROM salaries
LEFT JOIN teams 
	ON teams.teamid = salaries.teamid 
	AND teams.yearid = salaries.yearid
GROUP BY 
	teams.name, 
	salaries.yearid
ORDER BY
	SUM(salary) 
	DESC;

If I run the solutions code it returns a different answer so I guess it does make a difference if you join in two places rather then once but I don’t know why this is. Can anyone let me know why I should join on 'teams.teamid = salaries.teamid ’ and ‘teams.yearid = salaries.yearid’ rather then just one of them? Is it to do with grouping them correctly?

Thanks!

Hi!
I suppose this information can be useful here: "The SQL LEFT JOIN statement creates a table from the records of two or more tables. In the SQL LEFT JOIN statement, as in the SQL RIGHT JOIN statement, the order of the tables is important, as the result will depend on it. "