That same question made me do a double take when I noticed it also. I have heard a number of explanations from in antiquity genealogies weren't neccessarily literal but used to make some kind of point and some others. I considered this one the best I have come across I hope you find it helpful.
Some have tried to answer this by saying that Luke doesn’t give Jesus’ lineage through Joseph at all, but through Mary. This is not supported by the text. Luke states that Joseph was the son of Heli, not that Mary was the daughter of Heli...
To explain that issue, one needs to know something about how ancient Jewish genealogies work. Adoption, whether of a child or an adult, was common and affected which genealogical line one was ascribed to. For example, the faithful spy Caleb was biologically the son of a non-Jew named Jephunneh (Num. 32:12), but he was adopted into the tribe of Judah and ascribed to the line of Hezron (1 Chron. 2:18).
Adoption could take place posthumously. The most striking example is what is known as the levirate marriage (from the Latin levir = brother-in-law). If a man died childless, it was the duty of his brother to marry the widow and father a son on behalf of his brother. This son then would be posthumously "adopted" by the dead man and reckoned as his son in the family genealogy.
...But what about Jesus’ foster father, Joseph? Here we have more direct information. The second-century historian Julius Africanus, a native of Israel, records information given by Christ’s remaining family in his day. According to their family genealogy, Joseph’s grandfather Matthan (mentioned in Matthew) married a woman named Estha, who bore him a son named Jacob. After Matthan died, Estha married his relative Melchi (mentioned in Luke) and bore him a son named Heli (marrying relatives was common among Jews at this time). Jacob and Heli were thus half-brothers. Heli died childless, so Jacob married his widow and fathered Joseph, who was biologically the son of Jacob but legally the son of Heli (Eusebius, Ecclesiastical History 1:6:7).
There are other ways to reconcile the genealogies. The problem isn’t finding a way to reconcile them butâ€â€given the flexibility of ancient Hebrew genealogiesâ€â€finding which way is correct. More interesting is why the genealogies are different. Matthew stresses Christ as the successor of David and follows the line of kings. Luke stresses Christ as the Son of God and traces the line back to "Adam, the son of God" (Luke 3:38).
taken from
http://www.catholic.com/thisrock/1997/9712chap.asp where also the full article can be read.