A lawful food and the smell that may follow eating it are separate matters. Consuming garlic or onion does not permanently exclude a person from the mosque; the concern is an offensive smell that remains and disturbs others.
Case 1: Appropriate mouth care removes the smell before prayer, so the reason for avoiding the congregation is no longer present.
Case 2: A strong smell from breath or clothing visibly disturbs nearby worshippers; addressing that condition is part of communal etiquette.
مِمَّا يَتَأَذَّى مِنْهُ الْإِنْسُ highlights the distress experienced by people as the reason for consideration.