Our ancestors thought about death and what happened afterwards. They also wondered about thunder, earthquake, floods or other such things they feared. They needed an explanation, but they didn't have a clue. So they did what they could, used their imagination. In case of questions about death and what happens afterwards, they started believing that we become stars or we live on as spirit or we are reborn as another life form etc. In case of floods they started believing it was the tears of mother earth or because of an angry sky etc, and believed in similar explanations in case of thunder, earthquakes etc. It was the beginning of a made up system that fed of our ignorance, anxiety and fear. There was also the question of who created all this. They imagined the answer, a very powerful, supreme being made all this. They were also curious about how he created all this, why he created it and so on. So all along they made up a lot of things and also made reasons to believe it. People passed their ideas onto their friends and family, especially their children. Their beliefs spread through interactions and peaceful or violent preaching. Over time such beliefs got firmly established.
When we believe in something we tend to gather evidence in favor of our belief and disregard counter evidence. It is illogical to do so but it is how our brain works. It is called cognitive biases and it is one of the limitations to our logic. Both adults as well as children have it. One type of it is confirmation bias and it is the tendency to search for, interpret, favor and recall information in a way that confirms one’s preexisting beliefs or hypotheses. So if you believe god is showing you signs you will find reasons to believe it or if you believe god wants you to do something you will find reasons to believe so.
Children pick up the ideas around them. They not only learn what they are taught but also learn by observing and imitating. When a child is born and is surrounded by people who believe in god, he is probably going to start believing in god. If he has any doubt in the existence of a god, he will be told of the numerous reasons why god exist. Human logic takes time to develop fully. So the ideas of god, spirituality and religion will have limited logical filters to stop children from believing it. When these children become adults, many ideas will have already planted firmly in them. So when you ask a religious person where his god is, he will say god is everywhere or god is in heaven. If you ask him how he is sure, he will probably say he just knows it. He will not be telling you that he was told so by his family or friends or neighbors or priests, which is actually the case. He sees it like an indisputable universal law. Belief in a god who shares his wisdom with us is a similar idea. When a believer in god is told there is no god he will ask for proof, but he forgets that it was not proof which made him believe in god in the first place.