What is the meaning of these sentences?
Is "Sie haben die Prüfung zu machen," equivalent with "Sie müssen die Prüfung machen,"?
Why does this sentence "Er wollte verstehen, wie Deutschland zu einer XXX hatte werden können," uses hatten? Isn't hatten used for expressing 'wanting to have something' instead of 'to be something'?
What is the meaning of "Wie hat sie nur so dumm sein können,"? Is it "How has she can only be so stupid,"? Why is there hat, sein and können?
1) Yes, basically. It's more like the test is "on the list of things to do" than "must be done". Ich habe einige Besorgungen zu machen = "I have a few errands to run". I could also say "I must run some errands" but the emphasis is more on that they need to be done somehow, rather than that someone external is commanding me to do it.
2) It's a Plusquamperfekt subordinate clause, with a modal verb. Here hatte is the helping verb for the PQP construction, equivalent to "had" in English. The full verb here is werden ("to become"), or more specifically zu etwas werden ("to turn into something"). Normally a PQP construction would be ...war geworden, using sein instead of haben as the helping verb, and using the Partizip II form geworden. However the addition of the modal verb does a couple of things: It causes the need for an Ersatzinfinitiv, i.e. two infinitive forms instead of a PII, leading to werden können. It also requires the use of haben as the helping verb. This effect of the modal verb applies to all Perfekt tenses (see here). The conjugated helping verb also doesn't get bumped to the very end like would normally happen in a subordinate clause - instead it becomes the first verb in the stack of verbs at the end. Taking all that together, the meaning of that sentence is "He wanted to understand how Germany had been able to turn into a XXX".
3) The meaning is literally "How has she been able to be just so stupid?". I would phrase it as "How was she able to be just so stupid?" or even "How could she have been just so stupid?" because the perfect tense doesn't sound as natural in the English as it does in German, and German doesn't even have the option of a continuing tense. The strange feeling of this one probably comes from "can" being a defective verb in English - a verb without an infinitive. We use the phrase "to be able to" instead of 'to can', despite what some verb conjugator tools would have you believe.
dumm sein = "to be stupid"
etwas können = "to be able to do something"
dumm sein können = "to be able to be stupid"
Er konnte etwas = "He could do something" (Präteritum)
Er hat etwas gekonnt = "He has been able to do something" (Perfekt)
Then with another verb, the Perfekt is a bit irregular with the need for haben and the Ersatzinfinitiv again, due to the modal verb:
Er konnte schwimmen = "He could swim"
Er hat schwimmen können = "He has been able to swim" ("He was able to swim", "He could swim")
Er hat dumm sein können = "He has been able to be stupid" ("He was able to be stupid", "He could be stupid")
[Edited several times for additional information and corrections]
That's correct. The information in the Mittelfeld highlights that the helping verb now heads up the stack of verbs at the end (instead of closing that stack out as you would expect). Without any information in the Mittelfeld this isn't so obvious - it would look like it's still in the second position: ..., wie Deutschland hatte gewinnen können, for example.
I'll edit that to make it clearer.
1) Yes, just as "you have to do the test" is equivalent to "you must do the test".
2) Because "können" is a modal auxiliary. Modal auxiliaries are "müssen", "dürfen", "können", "möchten", "mögen", "wollen" and "sollen": Just like in Englisch the verbs "must", "may", "can", "shall", "would", "will" and "should" do, they modify the meaning of the verb (hence "modal" verb").
In German, the past perfect of auxiliary verbs is formed using not the participle, as you expect, but the infinitive:
"The player may not have touched the ball with the hand." Wrong: Der Spieler hat den Ball nicht mit der Hand berühren gedurft. Right: Der Spieler hat den Ball nicht mit der Hand berühren dürfen.
"The umpire has not wanted to give the goal." Wrong: Der Schiedsrichter hat das Tor gelten lassen gewollt. Right: Der Schiedsrichter hat das Tor gelten lassen wollen.
"You have not wanted to accept the decision." Wrong: Ihr habt die Entscheidung nicht annehmen gemocht. Right: Ihr habt die Entscheidung nicht annehmen mögen.
3) "Wie hat sie nur so dumm sein können?" (How could she have been so daft?) This sentence uses the past perfect of "sein können"
"hat": auxiliary verb to build the past perfect. Same role as "have" in the English sentence.
"sein": the actual verb. Same role as "been" in the English sentence.
"können": modal auxiliary. Same role as "could" in the English sentence.
"Wie hat sie nur so dumm sein gekonnt", as you might have wanted to phrase the sentence, is wrong because as explained above, in German you build the past perfect of verbs with a modal auxiliary using the infinite and not the participle.
Does this help with your problem?