ORGANIZATIONALLY (non-religious sense), both Mainline and Evangelical terms refer to 2 different ways that Protestant churches are governed in North America. Mainline churches are part of a hierarchy (sometimes called a denomination) but Evangelical churches are usually independent from one another so frequently called non-denominational. But for accountability, some evangelical churches belong to one or more fellowship / association such as the Southern Baptist Convention. Note that the term "denomination" is rather loosely applied, so a "non-denominational" association like Southern Baptist Convention is sometimes called a denomination.
Note that although the term "Mainline" appeared later (1920s) than the term "Evangelical" (1812), the older Mainline churches have existed much earlier. Presbyterian Church USA, for example, traced their origin to early 1700s when 7 Presbyterian ministers formed the first presbytery in 1706.
When it comes to RELIGIOUS BELIEFS, both mainline and evangelical churches are also Protestant in their theologies, derived ultimately from the teaching of the original reformers Martin Luther and Calvin (Reformed) or the later John Wesley (for Methodists). But the Evangelical brand of theology, which started in the early 18th century, has certain distinctive characteristics: a blend of Puritanism, Pietism, and Presbyterianism, stressing the conversion and experiential aspects rather than the membership and liturgical aspects of being a Christian. They also have the tendency to form revivals such as the Great Awakening. See wikipedia for more history.
But in the past 200 years or so, mainline Protestant theologies in North America grew more modernist / liberal (see a comparison in this 2004 PBS Frontline article). As the conservative factions within mainline churches began to split especially in the latter half of the 20th century, they formed their own churches which are mainline in government, but evangelical in teaching, such as the Evangelical Lutheran Church in America.
As a result the term "Evangelical" now is more associated with a distinctiveness in religious beliefs rather than in the non-religious sense because some mainline churches have adopted "evangelical" in their name. For the same reason, evangelical churches now are no longer uniformly Reformed in their beliefs because we now have evangelical churches that trace their origin to Lutheran, Methodist, and Anglican, theologies as well.