This won’t help in all circumstances, but in the majority of the cases could be prevented by:
#1 getting married
#2 having children WITH your spouse
In that order.
Or stop watching TV and getting conditioned to think that infanticide is ok.
In an ideal world, you are correct. This isn’t an ideal world. Premarital sex happens and babies are born out of wedlock. This would prevent innocent babies from being slaughtered and offer options to mothers who would other wise choose to have their babies. The point is to prevent abortion.