Mordred in Arthurian legend went from playing a small but important role as the killer of Arthur (and something of a Worthy Opponent) to becoming Arthur's evil illegitimate son and in earlier versions Evil Nephew who was connected to Morgan le Fay. In his earliest appearances, it isn't clear whether Mordred and Arthur were enemies at all - it is only said that Mordred fought in the battle in which Arthur was killed, without making it clear whether they fought on the same side or opposing ones.
Morgan le Fay herself was, in her earliest incarnations, a healer who helped Arthur by preserving his immortality, not the evil witch seen in later versions of the story.
A story that Arthur killed his own son in battle is actually one of the earliest recorded; presumably Mordred's villainy was developed to make this okay.
The Greeks from the Trojan War got this in general from the Romans and their later followers. The Romans were supposedly descended from the Trojans (specifically Aeneas), so naturally they weren't happy by the way their ancestors had been treated.
Set in Egyptian Mythology, although he feuded with Horus after killing Osiris, was originally the protector of Re from the evil serpent Apep, who he fought every night, and worshiped in his own right. After Egypt was split between the Upper and Lower Kingdoms, he became an evil god in Lower Egypt and his positive aspects were handed over to other deities. His worship as the god of foreigners almost entirely stopped after the Hyksos invaded Egypt.
He fell into decline as the trio of Osiris, Isis, and Horus rose in prominence. Different cult centers always had different opinions on everyone, of course. He was also associated with the desert, which seems to have gotten less awe and more resentment over time.
Loki of Norse Mythology, while always a trickster, steadily becomes more and more of a bad guy throughout the different stories. Some of this is assumed to be because of Christian influence.
Mostly occurred due to later writers missing that there are two distinctly different entities in Norse mythology named Loki and then further conflating the stories and linking them incorrectly, creating even more confusion. On top of that, some of the myths written later appear out of nowhere and contradict the earlier versions. For example, in the original form of the myth about Baldur's death Loki is never even mentioned, let alone involved.
The same thing happened to Loki's daughter Hel, the Norse goddess of death. Older myths suggest that she was originally a serene guide to the underworld for people who died of natural causes, and early descriptions of her realm Helheim aren't particularly negative. Later, more Christian-influenced myths portray her as a hag preparing an army of the dead for her father, and Helheim itself is the origin of the word "hell".
The gods of several religions show up in those of rival civilizations as demons.
Zoroastrian dualism was influencing popular religious understanding among its neighbors a lot around the beginning of the Current Era, and the traditional Hebrew approach of characterizing anything non-Hebrew as evil simply on the strength of it not being Hebrew, and therefore probably wanting to kill or take advantage of the Hebrews, was working less and less well in the civilized and cosmopolitan modernity of the first century. 'Badness' began to coalesce more into a figure rather than a force.
The early Christian sect/cult particularly needed a new definition of evil, since their recruitment among the Romans and other gentiles was huge, and xenophobia simply did not work as a basis anymore.
However, fusing every non-human and potentially non-human baddy mentioned in the texts into one being was a process that only began in the first centuries AD, and persisted all the way into the middle ages as Christian theology continued to develop.
Doing this to Hades (and occasionally other gods of death) has become its own subtrope, see Everybody Hates Hades.