The WHERE clause appears later in the query than the ON clause. Because of this, the WHERE clause predicates are evaluated after the ON clause predicates.
The result table for the ON clause has 18,034 rows. When the WHERE clause predicate
b.data_year_month=199707
is applied, you should expect the ensuing result table to have fewer rows because
this condition eliminates any results rows where b.data_year_month is null, and an outer join, by definition, produces results nulls on selection predicates.