The auction goes as shown below to 4, Partner leads the K. What is your plan?
Answer: 4 -
Declarer will want to trump his losing hearts in dummy.
You can prevent that by playing trump.
Partner won't know what you know (that dummy's diamonds are usless). Furthermore, he might (as here) have a trump holding where he can't lead them from his side.
You know a trump switch is right (and can't hurt from your side), so you win the A and play a trump. Declarer will lose a spade, club and 2 heart tricks. Without your trump switch, declarer gets to trump 2 hearts in dummy and makes the contract.