There is a sentence "I got married to her for seven years." Is the sentence right? Or should I correct the sentence into "I was married to her for seven years." or "I got married to her seven years ago."?
"To get" means to become, to enter into a particular existential state. "Get" refers to the action as it happens, not to an ongoing state or condition.
My shoe got wet when I stepped into the puddle.
Thus, we would not say:
not OKMy shoe got wet for seven years when I stepped into the puddle.
The time is the point in time of the stepping into the puddle: when I stepped.
This would be correct:
I got married in 2003 and was married [or "stayed married"] for seven years.
But you could say this:
My shoe stayed wet for seven years after I had stepped into that magic puddle.
There are areas of the US where "I got married to her for seven years" would be a common way of saying "We were married for seven years". It would not be considered standard correct English by anyone with a college education, but could be considered normal in some subcultures. Such speech is generally considered to be indicative of rural areas, where the overall level of education is low.
I cannot tell from your question if you're trying to write the sentence about yourself in some government essay, or attempting to interpret something you read or heard, or what. If it is your sentence, by all means 'correct' it. If you're just hearing from a random person, and you are not charged with helping that person learn better English, then don't.
"I got married to her for seven years" would imply that at the time of the marriage it was for an intended period of seven years. It's like "He was sent to prison for seven years". It's not currently an option for marriage in any jurisdiction of which I'm aware, and so it's probably not what you meant to say.