Which of "ungrammatical" or "grammatically incorrect" is prefered and why?
Both are used, but I believe linguists prefer the former. Grammaticality, as one linguist explained it to me, means "following the rules of the relevant scientific model that is used to describe how people speak". So it is strictly dependent on the model used, but in practice many linguists presume that there is consensus about most elements of the relevant model, so it mostly overlaps with "people actually use this within a certain group and they consider it normal".
The word "incorrect" may suggest that there is something wrong with straying from grammatically; I suspect that linguists do not use this much because they resent the implication. So I think that's why you will mostly see ungrammatical.
"Grammatical" is a modifier. Let's assume someone were to write a scientific article. If the information contained within the article is accurate, but poorly worded, we could say that the article was factually correct but grammatically incorrect.
If someone were to proofread the article and simply claim "This is incorrect" by what metric are they making the statement? The content, or the syntax? By including the modifier, we are now able to clarify the way in which the author was incorrect.
Grammatically incorrect implies the work is factually accurate, but has errors in grammar.
Gramatical is a term used to describe a phrase or word that follows the rules of grammar. To say something is grammatically incorrect would be like saying it is “right wrong” or “correct incorrect”. The term ungrammatical, on the other hand, suggests the phrase/word is not grammatical or does not follow the rules of grammar.