I can see how this might be difficult to understand but a little added information should help clear this up. I assume the passage you are referring to about "eye for eye" is part of a longer passage dealing with a particular issue. Here is what it says;
Exodus 21:22-25 If men fight, and hurt a woman with child, so that she gives birth prematurely, yet no harm follows, he shall surely be punished accordingly as the woman's husband imposes on him; and he shall pay as the judges [determine].
But if [any] harm follows, then you (the judges) shall give life for life,
"eye for eye, tooth for tooth, hand for hand, foot for foot,
"burn for burn, wound for wound, stripe for stripe.
The Lord is showing how those in authority were to exact justice. He is laying down what is a just punishment for a crime. He is also limiting the abuse of power in such things as he is putting a limit on what can be done in the name of justice. Thye could not remove two eyes if only one was lost and so on. This was not permission to take personal vengeance. This command is for the authorities to pronounce and carry out where there had been a crime.
The turning of the cheek reads as follows;
Matt 5:39 But I say unto you, That ye resist not evil: but whosoever shall smite thee on thy right cheek, turn to him the other also.
This passage is dealing with insults. If you notice it says if they smite you on the "right cheek". To do this, one has to use a back hand type of slap someone which is an attempt to provoke a fight through an insult. That still happens today in some cultures. A back handed slap is consider a way to insult so as to get a bigger confrontation going. The Lord is saying be the bigger man and turn to him the other also. In our culture it might be someone who is cussing you out, giving you the finger, or any other kind of insult. In such circumstances we are to "turn the cheek" so to speak.
Romans 12:17, 18 says it this way.
Recompense to no man evil for evil. Provide things honest in the sight of all men.
If it be possible, as much as lieth in you, live peaceably with all men.
If you notice the scripture leaves open the door a little. Not so much so when just an insult has been given but if the person refuses to not let it drop and starts to do actual harm then we can respond and should to protect ourselves. This is why it says "If it be possible", as much as lieth in you". Sadly some people just will not leave it at an insult and want to become physical. At that point we can defend ourselves.
So as you see there is no confrontation with the scripture. One is for dealing out justice in the courts (by a judge) and one is living in peace with your neighbor even in the mist of an insult. So if a crime has been done take it to the proper authorities so they can render justice. If you have been insulted turn your cheek. So the eye for an eye and the turning of the cheek, You can do both. The commandments can be kept.