SUM rows FROM a table only if one row have some match criteria with the rest of the rows
Is this close to what you expect?

SELECT a.id_player, SUM(b.goals) as accGoals, SUM(b.fouls) as accFouls
FROM boxscore as a
JOIN boxscore as b
    USING(id_team, id_boxscore)
WHERE a.id_player = 1
GROUP BY a.id_player
;


I.e. sum all goals, fouls from boxscore, where id_team and id_boxscore is the same as player 1