I recently hit upon a very clean, crystal clear example of how counting in defense can direct you to an unintuitive play.
Imagine you have these cards, sitting East, 4th position, no one vulnerable.
South, at your left, opens 1 Diamond. Your partner bids 1 Spade, and North doubles. You have a clear raise to 2 Spades, which is what you do.
Now, South bids 3 Clubs, and everybody passes. Your partner leads a trump against this contract, and this is the dummy you see:
Declarer plays small from dummy, you play the Ten, and South wins the first trick with the Ace. Declarer then leads another club to dummy, as your partner pitches a spade. Now you have the first piece of hard data about declarer's hand -- he has 5 clubs.
Counting in defense must be a constant habit. It must be done in every hand. And the more you do it, the easier it becomes. If you do not have this habit, you will never become an excellent player. Start right now and you will see that it will become painless after a few weeks.
Declarer having 5 clubs limits his possible distributions by quite a lot, since he opened with 1 Diamond. The bidding is also consistent with 2 spades in his hand, so your train of thought should be leaning now to a hand like 2=1=5=5 in South (2 spades, 1 heart, 5 diamonds, 5 clubs). He may also have 2=0=6=5, but it is much less likely. Or, he may have a singleton spade (leaving your partner with 6). You cannot decide for sure right now. But you must be making an active effort to visualize the entire distribution!
At trick 3, declarer leads a spade from dummy. You play the King (you want to draw the 3rd round of trumps if possible), but declarer wins with the Ace and plays a small diamond from hand. Your partner wins with the King, to play the Queen of spades (declarer follows with the Jack) and another spade to dummy's Nine and your Ten, trumped by declarer. These are the cards that you can see now:
So, declarer had a doubleton spade originally. His hand is almost certainly 2=1=5=5. (2=0=6=5 is still possible but quite a long shot -- and irrelevant, as we shall see). Declarer plays a diamond to dummy's Queen and plays a small heart from dummy.
Now is the time for the unintuitive play.
Declarer has 2 possible distributions at this point: 2=1=5=5 and 2=0=6=5. If he has the 2nd one, his hand is good apart from the club Queen, and he will make an overtrick. There is nothing you can do. (This is why this distribution is irrelevant).
If declarer has a singleton heart and it is the Ace, he will win this trick, ruff a diamond (establishing his diamonds -- he has the Ace, since the Queen won the trick), and his hand will once again become high apart from the club Queen.
But if he has a singleton heart and it is not the Ace, you can win this trick with the Queen and cash the 3rd trump. Does it matter? Let us count something else apart from the distribution -- declarer's tricks. He has 1 spade, 2 diamonds (the Ace and the Queen), 4 clubs in his hand (losing one of them to your Queen), and one ruff in dummy (you cannot prevent one ruff there).
That amounts to 8 tricks. His 9th trick can no longer be the King of hearts since he played a small one from dummy and you will win this trick with the Queen. (Yes, declarer misplayed the hand. It happens). It can also be the 5th diamond if he has time to establish that with a ruff and then cash it. Can he do all that?
Count the defense's tricks. You have 1 spade, 1 heart (after winning this trick with the Queen of hearts, if declarer has that hypothetical small singleton), 1 diamond and 1 club. Declarer cannot lose any other trick! This means that you can win the Queen of hearts, cash the Queen of clubs, and play a heart in this position:
When East leads a heart, declarer cannot avoid losing one more trick, the setting trick for your side. If he ruffs, his diamonds are not established; and if he establishes them with a ruff, he no longer has the entries to cash it. If he does not ruff the heart, your partner will win the Ace of hearts, the defense's 5th trick.
In other words, when declarer plays a small heart from dummy, you have a 100% correct defense, that will defeat the contract whenever it can be defeated: you must play second hand high, winning the trick with your Queen, cashing the 3rd trump, and playing a heart.
This is not a very difficult hand. All you have to do is to count the distribution and the tricks available to declarer. But you have to do it. Get into the habit of doing it and these hands will no longer escape you. (At the table, the player did not play the Queen of hearts. Since declarer had a singleton Jack, this Jack drove out partner's Ace, and the King of hearts in dummy became declarer's 9th trick).