They are both correct, but the meaning is different.
"I went to France two years ago" is the past simple of the verb 'go'. This sentence tells us about journey - a movement, say, from Spain to France. If you had a trip to France in 2013 you would say this.
'I was in France two years ago' is the past simple of 'be'. There is no movement involved. We don't know anything about when you went to France or when you left. All we know is that you were in France at some point during 2013.