Getting the previous matches is challenging, because of the home team/away team split. Instead, let's just focus on one team at a time, by having a separate record for each team.
The following gets the previous matchid for each team in the above table:
select id, match_date, team,
lag(id) over (partition by team order by match_date) as prev_matchid
from ((select id, match_date, home_team as team, 'home' as which
from matches
) union all
(select id, match_date, away_team as team, 'away' as which
from matches
)
) m;
You can join in the information about the match, if you like.