NY Yankees play against NY Mets during the season but only since 1997 : https://en.wikipedia.org/wiki/Mets%E2%80%93Yankees_rivalry#1997%E2%80%931999:_Interleague_regular_season_play_begins I was wondering how come an AL team plays against a NL one before they reached the play offs
In the current MLB divisional breakdown, there are 6 divisions of 5 teams each, organized into two leagues of 15. As a result, interleague play is mandatory in order to finish the schedule in a reasonable timeframe! Otherwise two teams would always have half of a week off at a time, and you'd have to add a few weeks to the schedule.
This changed in 2013, when the Astros were moved to the American League (remember, in 2005 they were the National League representative in the World Series). Prior to that, the National League had 16 teams (5 E,6 C,5 W) and the American League had 14 teams (5 E, 5 C, 4 W). (Conveniently, Houston is barely west of the westernmost AL Central team, Kansas City.)
Interleague Play was officially introduced in 1997, and the reason that it did not exist prior to that was that the American League and the National League formed as different, and competing, leagues (the American League was originally the American Association). While they would hold a championship each year, prior to the merger they had no incentive to play, and after the merger it became tradition not to (though they considered doing so every so often). By 1997, though, it was clear that games could be profitable - some teams (such as the Mets-Yankees and Cubs-White Sox) played exhibition games in season against each other, and they were very popular - and, as MLB is a business, they chose to formalize interleague play.