How does a baby know how to breath, swallow, or beat a heart?
Programmed. Genetically. How else do you think this all happens? Magic?