I am pretty sure the trick or treating came in because the kids (in certain pre-Halloween traditions) would go around from house to house, and the people living there handed out little treats and stuff, which probably wasn't much in those days other than like, some flowers and honey or something.