From Data to Creation: Understanding How Generative AI Functions