There is mystery in that, but it is not magic. In faith, we must lay claim to Baptism's promise.
When we baptize adults, we ask them to spend some time being with other Christians. Some congregations use a process called the Adult Catechumenate. Whatever the process, we hope that they will learn about being a Christian. Then, if they have discovered that they want to be part of the family, we invite them to be baptized.
However, most Lutherans are baptized as babies. Someone has to teach them what it means to be part of the Christian family; just as those babies are taught to walk and talk and all the other things babies must learn to grow into adulthood.
So we want parents to promise to bring their children to worship with us regularly and that they teach them how to pray and what it means to be a Christian. We are there to help them. We also expect the parents to help us to help them teach their children.