There is a law on the books prohibiting publishers from publishing descriminitory ads, even if they didn't write them.
That's the difference.
As a user of Facebook, this method of discrimination is markedly different than physically showing up to a house for rent and the home owner taking one look at you, scrunching up their face, and saying it's no longer available, tipping you off that what they are doing is illegal.
In the context of housing ads (or employment) these tools DO NOT have legal uses.
Thus they are illegal.
Targeting specific demographic using protected categories in other areas can be legal too.
As a pharmaceutical company you can target women, men, seniors for targeted medications. As a LGBTQ dating site you can target based on sexual orientation and cis/trans. It is not illegal. Housing and jobs (maybe something else) are covered by specific legislation.
The analogous argument for knives would be "In the context of torture knives don't have any legal uses. (So knife sellers need to put safe guards in preventing their knives from torturing people)".
I'm trying not to say anything too mean, so I'll just say this: learn some history.
At the very least Facebook could provide section-specific filter, if they haven’t already.