Moloch isnt actually a demon it was actually just name of a certain type of sacrificial practice that was used in old testemant yahweh worship.
Then to move away that this practice was done they created a scape goat pagan demon/god named moloch to take the blame for the old practice.
As for Lilith again depends on the mythos, if we are going that she’s based on Lilitu & Lamashtu. It was more of a matter of fate then anything else.
Man, Woman Or Child could be taken at anytime. She is literally wild aspect of nature and wilderness. Plus in this age medicine was scarce and health issues would have run rampant not mention wild animals sneaking into dwellings looking for food and mauling its inhabitants.
So naturally because these things are associated with the wild and haunted outside world instead of the safety of the village or city. So she would get the blame for sneaking into it, even though they built on her territory lol. Then that would get carried over to the Lilith in the judaic version.
If were talking the Mandean Zah’ril Lilith shes the angel of conception and protecter of children so that would mean shes the angel of death for them too.
Since gods and demons seem to have evolved with the times these things are not as associated with them as they once used to be.