This is the schedule for Red Sox in September in 2020.
Why there were 4 games against Rays while just 3 games against the Yankees?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Sports Stack Exchange is a question and answer site for participants in team and individual sport activities. It only takes a minute to sign up.Sign up to join this community
The answer is simple: they played the Yankees 7 times in July and August, while they played the Rays 6 times in July and August. Since the MLB schedule in 2020 was to play 10 games against each of the 4 same-division teams (for 40 games) plus 20 games against teams in the other division, that left 4 more games against the Rays, and 3 more against the Yankees to play in September.
See MLB's announcement on the 2020 schedule for more details, or Baseball-Reference's schedule and score list for the breakdown of their results.
Baseball teams typically play between two and four game sets against other teams; how many depends on the specific details of the schedule. Typically the Fri-Sun days are always against one team, and Tue-Weds are always against one team, and then Mon and/or Thurs go with one or the other of those sets (so they might play Tues-Thurs then Fri-Sun, or Mon-Weds then Thurs-Sun, or Mon-Thurs then Fri-Sun, or Tue-Weds then Fri-Sun, or something similar). The exact details just depends on how the other team's schedule matches theirs.