The same way your heart "knows" how to beat - it's a lower level function that happens without your conciousness. That's why people who are brain dead still live and breathe and swallow and digest and their hearts livers and kidneys still do their job.
>>how are they hard wired to search for milk
The ones who didn't died, to put it bluntly. Obviously not human babies, this evolutionary step happened long long time before the earliest hominids.
Do you have neurons in your brain that are pre-wired for these things? Is that encoded in your DNA? Like physically how is it inherited and the selective pressures applied?
On selective pressures: human babies that aren’t born with the ability to nurse, or foals born without the ability to walk—because their in-utero development didn’t allow it—historically don’t survive, and thus don’t reproduce.
Heart cells in a Petri dish will happily beat away.
This is kinda like explaining how a car works with "you fire and replace engineers until it moves".