In the movie the Witch King breaks Gandalf's staff. How did this happen and why (since it's not in the book)?
While Gandalf faces the Witch King in Minas Tirith, there is no record of Gandalf's staff being broken. The flaming sword is seen in the scene in the book, from Return of the King, The Seige of Gondor:
After that scene, Rohan arrives, and the Witch King flies off to handle them.
The Witch King's ability to destroy other's weapons is found in the books, however. From The Fellowship of the Ring, Flight to the Ford:
From the same chapter, after the wraiths are driven off, Aragorn is examining the cloak left by the Witch King:
It's likely that Jackson interpreted Gandalf's raised staff as a "blade to pierce" the Witch King. It doesn't say in the books whether the WK could destroy an Istari's staff, but I think that scene is Jackson's interpretation of these scenes in the book.
AFAIK, there was no Jackson commentary on that specific scene, so one can only speculate.
As for "Why", the most cogent speculation I have seen on the forums is that the scene served to:
A second theory was that this was to highlight the power and contribution of the World of Men - Gandalf is almost beaten and can be killed by such a powerful adversary, yet saved by the fact that WK needs to go away and deal with Rohirrim - which, if you know the backstory of Istari, actually jibes with Tolkien's overall vision of the order of things (Olorin's mission is to inspire Middle Earthers to fight Sauron, not to fight him himself with his Mayar powers).
This has further symbolic significance in that this mirrors Gandalf the White's breaking of Saruman's staff.
As for "How", there just isn't any info. WK holds a flaming sword, stares at Gandalf, and the staff explodes.