So, I know the sentence should be like this what country are you from? But I also want to know if it is wrong to write what country you are from? If it is wrong then why please explain?
"What country you are from?" is not a complete question-sentence. It refers to the answer of the question. You can put it in other sentences, including question-sentences:
"I don't know what country you are from."
"Please tell me what country you are from."
"Does he know what country you are from?"
But on its own, it is not a question and not a sentence. To make it into a question, change order of the words "you" and "are":
"What country are you from?"
Lots of questions in English work like this:
✘ "What your name is?"
✔ "What is your name?"
✔ "I don't know what your name is."
✔ "Please tell me what your name is."
✘ "How you are feeling today?"
✔ "How are you feeling today?"
✔ "I don't know how you are feeling today."
✔ "Please tell me how you are feeling today."
✘ "What you are doing?"
✔ "What are you doing?"
✔ "I don't know what you are doing."
✔ "Please tell me what you are doing."
Yes/no questions are a bit different. They use mostly the same word order as who/what/how/etc. questions, but to refer to the answer of a yes/no question, you need add "if", "whether", or something similar.
✘ "You are from France?"
Again, we have the wrong word order for a question. In question word order, it's this:
✔ "Are you from France?"
But "you are from France" is different from "what country you are from" because it is a complete statement. This causes funny things to happen if we try to use it in a "please tell me" sentence:
✘ "Please tell me you are from France."—correct grammar, but incorrect meaning!
This asks you to say, "I am from France," even if you are not from France! To ask for meaningful information, use one of these:
✔ "Please tell me if you are from France."
✔ "Please tell me whether you are from France."
✔ "Please tell me whether or not you are from France."
(But these sound strange, so you should probably just ask "Are you from France?" instead.)
Questions using other verbs
All of the examples so far use the same verb: to be, or is/am/are/was/were. Questions using other verbs work differently. Suppose you want to ask me if I speak English:
✘ "You speak English?"
We have the same problem as before. This has the word order of a statement. But if you try to use rule for yes/no questions, you might come up with this:
✘ "Speak you English?"
This word order would be correct in German, but not in English. This is because most English verbs cannot move around in the sentence the way is/am/are/was/were can. The correct question is this:
✔ "Do you speak English?"
What? Where did that "do" come from? In a way, it was there all along, but invisible. "Do" is an auxiliary verb, or "helping" verb, which is attached to another verb. You can add "do" to almost any sentence without changing the meaning much, so what we did was change "You speak English," to "You do speak English," and then changed the order of the "you" and the "do".
This works with any helping verb—will, have, must, may—but "do" is the only one that doesn't change the meaning of the sentence, so it's the one that is most often used in questions. In this case, "Can you speak English?" also would have worked, but that's only because "do you speak English" is already a question about ability.
Do you understand?
As a simple question, the following is how it's normally phrased:
✔ "Excuse me, what country are you from?"
If it were phrased in the inverted manner, it would sound very strange—to the point of being thought of as wrong:
✘ "Excuse me, what country you are from?"
Hearing the inverted version, while understandable, would at least single the person out as someone who probably doesn't speak English natively.
That being said, the inverted version can be used (and sound perfectly natural) in the right context:
"She asked me what country I was from."
✔ "What country you are from?"
"Yes, that was her question."
In fact, in this particular context, What country are you from?, while not wrong, would sound a little strange. So, here, it's the inverted version that's the more natural of the two.
It has something do with a combination of reported speech and the echoing back of something that changes the situation.
Unfortunately, I can't express this as a straightforward rule. Much here depends on simple idiomatic use as well as context.