The real answer isn't that I knew what my opponent would do, but rather that I had a specific defensive timing optimized to deal with that particular mixup. Let me explain: fox's shine is +2 on block, so a perfect double shine will hit on the opponent's second actionable frame (3 frames of jump squat, shine hits on the 4th frame, but fox has a 2 frame advantage). If you buffer a roll to avoid a shine grab, you will be hit by the shine; roll is not invincible until frame 4, so fox actually has 1 frame of leniency for hitting this. Shine-grab, on the other hand, does not hit until the opponent's sixth actionable frame (JC grab out of the shine takes 8 frames, and again, fox is +2). So if, instead of buffering the roll, you time it on your 3rd actionable frame (well, you input it on the frame before this, because the game will read it on the next possible frame), you can avoid the shine-grab while also avoiding all double shine timings which beat a buffered roll! I'll put some tables below showing why this is the case, if it isn't clear already. For reference, after fox shines a shield there are 3 frames of hitlag and 3 frames he has to wait in shine before he can do anything; the +2 on block already takes that into account, so all the tables will just start counting from fox's first actionable frame (aka the first frame he can jump out of shine, which is 2 frames before the opponent can move).
|jump 3||you can move now, roll 1|
|shine||roll 2 (you get hit here)|
|roll 4 (invincible, too bad you already got hit!)|
|jump 3||you can move now, delay 1|
|shine||roll 1 (you get hit here)|
|roll 2 (you already got hit, don't die!!)|
|jump 3||you can move now, delay 1|
|roll 1 (nothing will happen because you're in shieldstun from the shine!)|
|grab 2||you can move now, delay 1|
|grab 3||delay 2|
|grab 4||roll 1|
|grab 5||roll 2|
|grab 6||roll 3|
|grab 7||roll 4 (you're invincible the frame the grab hits!)|
Hopefully the visuals help explain it a bit. Obviously varying degrees of perfection on each end greatly change the result. For example, if the fox isn't frame perfect shine-grabbing you can do a 3 frame delay before rolling to beat the shine-grab, which allows you to account for more potential double shine timings. This type of thinking isn't only useful vs fox and falco pressure! It can also be applied to other fairly common situations in melee; I'll give one more example, and beyond that I trust you to use this to brainstorm timings for various defensive situations.
Let's take the situation where sheik fairs your shield...what do you do? Well, consider it from sheik's side, for a moment. Unless she is already spaced outside of your grab range, she needs to account for an immediate shield grab somehow (unless she's willing to read that you won't shield grab immediately, a huge risk for her). So how can she beat someone who shield grabs her fair? She can buffer a roll or spotdodge, dash backwards after the fair, or throw out a move (jab or dsmash, for example). Given that she will generally take an action to stay safe after fair, you can time a WD OoS to account for all of those things! The trick is that you time the WD so that you don't get hit by an attack immediately after fair. I won't go through the trouble of making tables again, but if I recall correctly sheik's perfect fair is -2 (or sometthing like that) on block. So you take this into account, and delay your WD OoS so that you'd block her move right before trying to WD, but if she doesn't throw out a move you can escape before she can punish you. For example, most of the good sheiks in the current meta do a sequence along the lines of fair-->dash back-->dash back in-->grab (hypothetically, you may have missed a shield grab trying to punish her fair). I've seen a lot of players do things like a delayed shield grab to beat the sheik dashing back in, which is fine, but by employing the WD OoS at an optimized timing to account for her best options (dash back being probably her safest one) you're already gone by the time she dashes back towards you!
So if she throws out a move, you block it (although you attempted to input WD already, but shieldstun will prevent you from doing so) and punish it. If she tries to buffer a roll/spotdodge or dash back, you evade her before she can do anything to punish you. Her only way of countering this is by taking a meaningful risk (such as delaying her attack after the fair to catch your WD, but that makes her fair shield grabbable). I'm not saying that using this tactic is unbeatable for sheik, far from it. I am saying, however, that you force her to make a risky read to hit you, in a situation that's generally considered strong for sheik.
The essence of "optimizing" your defensive timings is that you take into account their strongest options that they need to use to avoid a standard response from you(i.e. sheik needs to account for an immediate shield grab from you after her fair). By assessing their strongest options, you can come up with a timing that simultaneously deals with many of their options, which will generally force them to take a risk if they want to call you out on it. This will be different for each character and situation of course, but developing a standardized option set in all these common situations can go a long way in improving your defensive gameplay.