Why does the ESV contradict itself in John 1:18 versus John 17:3?
The ESV contradicts itself because it has an unabashed 'Trinitarian' bias, as do many a translation with us today. Their translation of the original Greek, in John 1:18, is 'gross', to put it bluntly. They not only remove 'begotten' when translating 'monogenes', which is best translated as 'only begotten', but they also upgrade the Son's divinity, so as to make him equal with the Almighty God. Consequently, we should not be reading:- ...the only God, who is at the Father's side, but should in fact be reading:- ...the only begotten (g)od, who is at the Father's side. We are talking about the 'uniqueness' of the Son's relationship to the Father after all.
I talked about the above meaning of 'monogenes' in much greater length last June, which I produce again here for greater benefit:-
..."Even though now an out moded expression, the most accurate translation of the Greek, here in question in John 1:18, is "Only Begotten" which is adjectival to the second "theos". In the NT it appears 9 times (more often in the Septuagint). It's meaning is archaic (of a child) being the single of it's kind, "only" offspring of it's father. In this case the "Father". In Heb, 11:17 we see that the "OB" is used in respect of the covenantal son Isaac, of Abraham, even though Abraham had previously fathered Ishmael, and later would father several sons through Keturah. God's covenant, however, was established only through Isaac and who was the only son in his father's household at the time Abraham offered him up.
More often than not, when one thinks of the "only begotten", one usually perceives that the person being talked about is the spiritual personage of Jesus (another only begotten covenantal son) and indeed this is the case in John 1:14; 3:16,18 and 1 John 4:9 but possibly not so much in John 1:18. The Greek word for the "OB" is "Monogenes" and the often question is: Are we talking about a Monogenes "theos", or a Monogenes "huios"? (God/god, or, Son), as some "MSS", ancient and more modern, invoke Son rather than God/god in John 1:18. Dan Wallace prefers god (with a small "g"). The "KJV" begs to differ and prefers Son, and the "NASB" prefers God (with a capital G), so it's irresolute. The weightier "MSS" support is towards "theos", rather than "huios", being more for the sake of deity, which is after all more contextual when one really get's down to determining true meaning. So, are we talking "God" here, or, are we really talking in respect of "a god". The word "Monogenes", also expresses "uniqueness" as opposed to mere "sonship". Here we have the son revealing the Father and we are being reminded of the son's covenantal role as the soon to be mediator of salvation. One should note that the declension of the second theos here is declined the same as the second theos in John 1:1c, again we have an anarthrous pre verbal noun , not having an article/determiner, so neither definite or indefinite, although in John 1:1c, an indefinite article is thought to be implied, resulting in an "a god" translation, in non-trinitarian circles at least, but not to the exclusion of deity. It's the quality of Jesus' deity that's in question in both John 1:1 and John 1:18. What's also in question, in respect of both verses, is as to whether we are talking about an indefinite Jesus, or a qualitative Jesus. Is one talking about Jesus as one of a class of others, or are we talking about his essence/nature. Even if either one were to be fact, I don't think, when giving the two context's all due consideration, that we should be equating Jesus with the Almighty.... What we are talking about is the "only begotten" Son of God; the firstborn; the "covenantal" Son; in the bosom position of (with) the Father; occupying a special place of favor with that one; who had to be "begat/created"; whereas the Almighty already "WAS"...
As to which ESV translation is correct? I find nothing wrong with their rendering of John 17:3.