From what I can gather, one studies what the opponent has been playing, and prepare responses for their favourite lines. The problem is, there's no guarantee the opponent will play a given opening. For example, suppose I'm playing against Kramnik with white. Kramnik is the person who famously defeated Kasparov with the Ruy Lopez Berlin, so I prepare something special for 1. e4 e5 2. Nf3 Nc6 3. Bb5 Nf6. But then in the actual game, all I can control is the first move. After 1. e4, it's conceivable that Kramnik plays 1...d5, 1...Nc6, or 1...e6.
My guess would be that GMs have some kind of plan mapped out for every possible response - but that sounds like a formidable amount of lines to remember, especially with opening lines running 15+ moves deep.