Declarer would've done well to count the hand from one hand or t'other before rushing to draw trump, which suit offers a lot of communication as declarer gets out the trump. If you count from dummy, you can dismiss concern for diamonds or spades (while taking the finesse, of course), but there are two low hearts to concern yourself with. If you count out from the closed hand, you'll just hafta hope that either diamonds split 3-3 or that the spade hook is off, but in any case, you've got a third round of spades to ruff, without any if's and's or but's.
As for spades, with only 5 cards in the suit, I'd recommend taking that finesse early, the probability of running into a singleton in one hand getting a second-round ruff being remote. Unfortunately this declarer took three rounds of trump, cutting down his communication severely before tackling spades. Declarer won the opening lead in dummy, and cashed the Q J of clubs, getting the news of a 4-1 break, West holding the 4, which leaves him in the wrong hand for the spade hook. So he came to the A of trump and took a losing finesse.
East returned a spade after taking his K, and we see that declarer must now come to the closed hand on a diamond, ruff a spade, cash the A of diamonds and, holding his breath, lead a third round of diamonds to the closed hand , note the 3-3 split, draw West's last trump and claim.
Unfortunately declarer didn't recognize his need for that third round ruff of spades. For after winning with the A of spades, he cashed dummy's last high heart, for no good reason, though it did him no harm, then the A of diamonds, and now a diamond to the K, and the K of trump was cashed. The K of clubs was cashed? In other words, we're going to hand over the setting trick to the opposition? Or that third spade in the closed hand is going to metamorphose into a winner? Oh, maybe the opponents are going to toss away their high spades? Actually, West couldn't discard his winning spade if he tried!
Here is the whole hand:
A Q
A K 7 5
A 7 2
Q J 9 5
J 9 6 3
K 8 5 2
Q 2
J 10 8 4 3
9 6 3
J 10 5
10 6 4 2
7
10 7 4
9 6
K Q 8 4
A K 8 3
Declarer should win the opening lead in dummy, come to the closed hand on a trump to the A, take the spade hook -- which loses. This particular East returned a spade, which did declarer no harm. At that point, he can come to the closed hand on a diamond, ruff a spade with the 8, cash the Q J of clubs, getting news of the bad break, and declarer is now at the mercy of a 3-3 diamond split.
Even if there weren't such a break, he wouldn't have any more trump in dummy to ruff the fourth round anyway. Now, to avoid blocking the suit, he cashes the A of diamonds, leads to the K and holds his breath. But there it is: an even break, along with the bad break in clubs, and declarer now cashes the last round of trump before cashing his established 13th diamond.