You are correct to say that:
(1) Both they are students.
However, (2) They both are students
is also incorrect.
In these sentences, both is used as an adverb. The correct position of the adverb is after the verb to be and before other verbs.
The correct forms are:
They are both students. (Both comes after the verb to be)
They both like reading. (Both comes before other verbs).
The following sentences are correct and there is no difference in their meaning.
(4) Both the girls are students.
(5) Both of the girls are students.
I hope this will be of help to you.