Why are these sentences ungrammatical?
Because when "but" is used twice in one sentence, it's not clear what the author means, as "but" implies a strong counterpoint to another thing, but if there are two other things, then the way their counterpoints apply to each other is unclear (and often in practice, doesn't make complete sense).
Is the reason syntactic or semantic?
Both, but I expect that the reason for the syntactic rule is the semantic mess made by using two "buts".
It seems to me that the issue is more the re-use of the word "but" (which is used to frame an entire clause as an opposition) and the question thus created about the relation between the first part and the third. It has me wondering, "why is the author is strangely using "but" twice like that?" Compare to the same structure with one "yet" and one "but":
The queen tried to kill Snow White but Snow White escaped yet she went through much hardship.
The queen tried to kill Snow White yet Snow White escaped but she
went through much hardship.
The mountain climbers were tired but happy yet bankrupt.
The mountain climbers were tired yet happy but bankrupt.
This is still awkward, but clearer. The author hopefully means that the "but" relation is the major opposition of the clause, while the "yet" is a secondary opposition which can be of a different type (and sentence-grammar-analyzers can ignore it).
When "but" is used twice, it suggests to me that the same type of opposition applies between three expressions, which asks the readers to form a kind of logical triangle in their minds all at once, where the relation between all three may not be so clear or even make sense. When I read two "buts" in a row, I tend to think, "wait, what?" and stop to consider the three potential implied relationships, and whether they're all the same or different.
That is, in "1 but 2 yet 3", 1 and 3 are both adverse to something about 2, but 1 and 3 may not be adverse to each other - they may be about different things. In both of the examples above, this seems to be because the subject is a person and their well-being is the concern of the sentence, and a person has various aspects to their well-being.
So consider the edit:
- The queen tried to kill Snow White but Snow White escaped. She escaped but went through much hardship.
This clarifies that there are two relationships, and does not have me thinking what the original single sentence with two "buts" did, which was: So is the author implying some relationship between "The queen tried to kill Snow White" and "she went through much hardship", or are they just writing sloppily?