Essentially they scrape it from whoever's not blocking their bots. It then becomes part of the model used to train the thing to generate a likely sounding response, or, in this case, images that are likely to meet the criteria specified by the prompt given.