https://www.espn.com/mlb/story/_/id/32328371/mlb-playoffs-everything-need-know-tiebreakers-wild-cards-last-day-mlb-season
OK, here's what can happen:
1. If the Yankees and Red Sox win, or if they lose and the Blue Jays and Mariners both lose, as well, it's Yankees-Red Sox in the wild-card game on Tuesday at Fenway Park. (The Red Sox won the season series 10-9.)
MLB playoff tracker: AL wild-card scenarios, key games and who has clinched a postseason spot
6hESPN.com
2. If there's a two-team tie for the second wild card, the two teams will play a tiebreaker game on Monday to earn a chance in Tuesday's wild-card game. The home team will be the squad with the better head-to-head record. Scenarios in play: Yankees at Blue Jays, Mariners at Yankees, Blue Jays at Red Sox, Mariners at Red Sox.
3. If three teams end up tied for two wild-card spots, teams are given A, B and C designations based on combined head-to-head winning percentage. Club A hosts Club B on Monday, and the winner is one wild-card team. The loser then travels to Club C to determine the second wild-card team (in this scenario, the wild-card game is pushed back to Wednesday). The team with the best percentage gets first pick on its designation, etc. Scenarios in play with order of winning percentage (presumably, the team with the first pick would choose the A designation, giving it two chances to win one game):
BOS-TOR-NYY
BOS-NYY-SEA
4. If there's a three-team tie for the second wild card, teams are given the same A, B and C designations. Club A hosts Club B on Monday and the winner of that game hosts Club C on Tuesday, with the wild-card game again pushed back to Wednesday. Scenarios in play with order of winning percentage (so the team with the best percentage chooses between winning two games at home or winning one game on the road):
TOR-NYY-SEA
BOS-SEA-TOR
5. If there's a four-way tie for two wild cards -- that would require the Blue Jays and Mariners to win, and the Yankees and Red Sox to lose -- teams are given A, B, C and D designations. Club A hosts Club B and Club C hosts Club D, with the two winners advancing to the wild-card game. FiveThirtyEight gives this an 8% chance of happening. The order of selection goes Boston, Toronto, New York and Seattle, so Boston and Toronto would play home games, leaving the Yankees to choose between playing at Boston or at Toronto. How fun would that be?