I guess Lewis Carroll came up with these stories to entertain Alice and her sisters, but he was an educated professor, so he was aware of the literary traditions.