SMILE gives some clues on how the grapple glitch works. In SMILE, scroll blocks are depicted by red circles containing the letter S and arrow blocks can be used to extend the reach of scroll blocks. Normally, when Samus steps on a scroll block or any of the arrows connected to it, it's programmed to lock or unlock a section of a room and allow the camera to scroll into that section.
For some reason, when vertical arrows connected to scroll blocks don't keep going until they reach a solid block, it causes problems with grapple.
The first image is from a clean rom. Samus must be touching the column that the circled scroll blocks are in, even if it's only by one pixel. If you remove those scroll blocks, it completely stops the glitch from working.
The glitch normally doesn't work while Samus is standing in the other two columns of scroll blocks, but removing the top two arrows on the rightmost one so that it looks like the second image causes the glitch to work in that column too.
One of the programmers probably puked on the room inside Kraid's lair. I have very limited knowledge of how SMILE works, but I think I see the problem. This image doesn't show it, but SMILE shows certain blocks in the area as horizontal / vertical blocks. I think these can be used for the same purpose as the red arrows from the first two images. If the arrows had been used instead, it would've looked like this:
This is consistent with what I found in the other room. The glitch works here because the chain of scroll blocks depicted by the blue arrow doesn't keep going until it reaches a solid block; it just collides with the green arrow instead. Removing the vertical/horizontal blocks also stops the glitch from working here.