Memorization to Generalization: Emergence of Diffusion Models from Associative Memory