Way back then, they made a bad law for a good reason. A better-worded Fourteenth Amendment would have avoided the unintended consequences.
Nonetheless, it’s a simple solution. Just make a law: if the mother enters the country for this purpose, she pays by spending five to ten years in a federal prison followed by permanent deportation.
I don’t know. It might be a little extreme. However, if the law were enforced, it is likely that it wouldn’t need to be enforced all that often.