Tolkien’s mythology was based on Christianity, pure and simple, or perhaps better, pure and complicated.
Traditonal Christian legend considers Satan to be the source of all
evil.
Melkor is just Satan novelized.
As to how Satan became evil, that is a problem in Christian theology. The Fourth Lateran Council (1213) claimed that “the Devil and the other demons were created by
God good in their nature but they by themselves have made themselves evil.” St. Thomas of Acquinas considered that Satan’s main sin was pride and trying to be like God.
In short, in Tolkien’s Christian, Roman Catholic universe, that Satan exists and has long been evil is a given that does not need to be explained. Many, although not all, Roman Catholic theologians (and Protestant theologians) make Satan to be the most powerful of the angels before his fall. Tolkien explicitly says only that Melkor was “the mightiest of those
Ainur who came into the world,” leaving open the possibility of mightier Ainûr who did not come to
Arda.
But to answer any question as to how Satan originally became evil and why God did not do something about it earlier, one can only go to Christian theologians, most of whom will admit ignorance on that head. A few have answers but these answers mostly disagree with one another.