Because the law happens to make the advertising platforms liable. It does so because enforcing this as an individual crime is impractical for the government, so it essentially outsources the work to advertising publishers.
See e.g. a similar case brought against the New York Times in the 80s, and the resulting investment by the Times in a reviewing process where humans went through submitted ads looking for discrimination.
You can also conduct illegal activity via Facebook messenger of groups, does that make it Facebook's fault?