You seem to want match info for a team when it was home and when it was guest:
select t.id, count(*), sum(...), ...
from teams t join matches m
where t.id = m.home or t.id=m.guest
group by (t.id)
Your information for a match other than team id may now also be separate for home and guest. Eg matches columns home_score & away_score. Then you need to use "or" to get at that information too:
select t.id,
case when when t.id = m.home then "home" when t.id = m.guest then "guest" end case) as role,
sum(*) as games_played,
sum(case when t.id = m.home then m.home_score when t.id = m.guest then m.home_guest end case) as total_score,
case when t.id = m.home then m.home_penalties when t.id = m.guest then m.home_penalties end case) as total_penalties,
...
This could be written with fewer case expressions but probably more slowly as:
select id, role, count(*), sum(score), sum(penalty)
from teams t
join (select home as team, "home" as role, m.home_score as score, m.home_penalty as penalty, ..., match.* from matches)
union
select away as team, "away" as role, m.away_score as score, m.away_penalty as penalty, ..., match.* from matches) m
on t.id = m.team
group by (t.id)
To avoid these complications, you could keep whether a team is home or away (role) plus its results per match in a table and keep only the team pairings of a match in another table then define matches with its home_/away_ columns as a view of them.