Most modern AI image generators are built on a technique called diffusion. During training, the model is shown real images that have been progressively corrupted with random noise, and it learns to predict what noise was added at each step so it can be removed.
To generate a new image, the process runs backward: the model starts with pure random noise and repeatedly "denoises" it, guided by your text prompt, until a coherent picture emerges. Each step nudges the noisy canvas slightly closer to something that matches the description you gave.
The results can be strikingly creative, but they inherit the biases and gaps of their training data, and they can struggle with precise details like hands, text, or exact counts of objects. Most tools are improving quickly on those specific weaknesses as the underlying models get better at fine spatial detail.