This is actually a redactional error. As Amichai points out, in Chronicles 21:25 it is clearly Lahmi the brother of Goliath that is slain by Elhanan, not Goliath.
According to this revealing article, originally the verse in Samuel read exactly like the one in Chronicles. But then errors crept in the text and became defective; instead of את לחמי אחי גלית הגתי it read את לחמי את גלית הגתי. Instaed of אחי, "the brother", it became את "the". This of course presented a problem for a subsequent scribe as the verse wasn't readable, "And Elhanan son of Jaare-Oregim killed Lahmi, Goliath the Gittite." (The word Oregim was also in the wrong place, as it clearly belongs to the end of the verse כמנור ארגים. This was yet another error in redaction). Whom did he kill, Goliath or Lahmi? Besides, Lahmi never occurs anywhere else in the bible as a proper name (besides for the Lahmi that appears in Chronicles, of course, of which this particular scribe wasn't aware). In order to deal with this problem, the scribe edited the words את לחמי to בית הלחמי, “the Bethlehemite.” Now the verse would read better, “And Elhanan, son of Jaare-Oregim the Bethlehemite, killed Goliath the Gittite.”
This is clearly the best solution to resolve the apparent contradiction in the book of Samuel itself, plus it effectively explains the similarities between Samuel and Chronicles and the minor differences that exist between them.