It has absolutely no idea what it's doing. It just saw a bunch of words and decided this was a reasonable career path.
Every word is treated as a token. The generator learns which tokens tend to appear beside other tokens and which sentence structures occur in the examples.