I don’t quite understand how your database is setup. Does your team table have a composite primary key with those 2 id fields? Shouldn’t the match team id columns be paired up with the team.team_id column?
Anyway from the team model, I think what you should be doing is creating 2 has_many relations. One to grab matches where that team is the "home" team, and another where they are the "away" team. If you want to grab all the matches for a specific team, then I think it would be better to start from match model