Their quality doesn't matter, it's not what defines them as being mainline titles or not. That's kind of the whole point of this thread, isn't it?The best 2D Mario game after Super Mario World 2 reviewed worse than the worst-reviewed 3D Mario, so this straight up isn't true. None of the 2D Mario games beyond Super Mario World 2 are spoke of as classics.
The NSMB games are mainline Mario titles because 1) they're regular platformers and not RPGs or sports games or a funky thing like Mario Maker, 2) they were developed in-house at Nintendo, 3) they were specifically made and branded as new mainline entries, signalling the return of 2D Mario after a nearly 15 year gap since the last title, 4) Nintendo has after release consistently treated them in a way that indicates they consider them to be part of the core series.