Complex sentence: The Andromeda Galaxy has appeared in a number of science fiction works, as a source of alien life forms that invade the Milky Way galaxy, or as a setting for alien worlds and territories.
Split into simpler sentences: The Andromeda Galaxy has appeared in a number of science fiction works, often as a source of alien life forms that are in the process of invading the Milky Way galaxy. Other works use the galaxy as a setting for alien worlds and territories.