Don't ask yourself "how" to defend but ask yourself "why" that he plans a medivac drop.
Impressive medivac play is shown in Day Daily #248 - Dealing with Duckload
(14:17 - 27:00),
let's see at what we have to note and can learn from watching this video:
- Long Rush Distance, so Protoss techs to Colossi to counter a Bio Ball.
- Terran knows Protoss is building up a strong army, so he must prevent the attack.
- Constant harassment with Medivac Drops allows Terran to expand back home.
- Protoss has to split his army to cover all sides and can only harass with a Warp Prism.
Ugh... What went wrong at Protoss' side?
- Colossi are slow to handle Medivac drops, they would be more useful later in the game.
- Terran knows nothing is going to counter his Medivacs, as Protoss has made a Robotics Bay.
- Because Protoss plans a defensive build, Terran knows that there won't be early harassment.
- Colossi are slow and 2 Gateways don't allow for much units, so Terran splits his army.
Ah... What could Protoss have done instead?
- Air: Early Phoenix Harassment (and to hunt the Medivacs) and/or building enough Void Rays.
- Templar: Stalkers can Blink, HTs can handle the Bio Ball and DTs are handy for harassment.
As for how, you'll find the answer in the Help in-game or at Liquipedia II, there isn't much more to say:
How can I prepare to defend from that in the best way if I know that it is planned?
If you learned why you'll have a better composition to handle the issue.
We could list any combination, but inspecting what went wrong will learn you how to do that yourself...
How can I be more or less defended against unexpected drop?
Scouting and map control are key. Don't mindlessly attack, but know what your opponent is doing...
Note: If you plan to use Tanks, have something to counter air or else he'll simple drop on your tank.