Okay I'll tell you. Kanamara Matsuri is the festival of the Iron wiener. It is for fertility that's why their little girls rub it. Prayers attached to the base of the penis are for fertility. Penis shaped candies are.... i got no explanation for that.
You see a long long time ago (approximately 300 years) in a land far far away (Japan) their lived a hot chick. So a man married her and tried to take her virginity and BAM this vaginal crotch demon bit off his wiener and he died. So she cries and mourns and another man marries her and BAM the crotch demon bites off another wiener so she goes to a Shinto Priest.
He says come back tomorrow, I think I have a plan. So when she shows up at the shrine he is there with the blacksmith who had forged an IRON WIENER! so she masturbates with it and the demon bites the wiener and it breaks his teeth and when he digs his claws in trying to tear it off they YANK him out and stomp on his head and kill him.
Then the blacksmith marries her and lives happily ever after and ever since Shinto priests hold the festival of the iron wiener to promote fertility, marriage, and demon stomping. In some versions of the story the priest gets to bang her once too. but I think the priest made that part up.