iirc, the grab command (Z on a GC controller) also maps to the shield button as well, since grab is L/R + A (not sure what it is for Classic Controller, but just replace L/R and A with what's on the CC).
Also, there are 10 frames of buffer in Brawl as I'm sure you know.
I believe you can buffer shield grabs because you're already holding L/R and the buffered input that is read by the game is the A button.
But when you try to press the grab button out of doing a attack or any kind of move, if you don't wait until the move is over, you'll probably buffer the shield. Since grab is mapped to L/R + A and doesn't have its own separate input, the buffered input that will be read by the game is L/R, aka the shield button. I think this is because L/R has priority over the A button since you have to press L/R first and then press A second to grab. Also, I don't think you can enter multiple button inputs from a buffer. Just one (though if I remember BDACUS, then maybe that's not the case.... forget I said that....). So if you tried to do a forward air or something and you wanted to grab after, if you grab prematurely during the buffer frames of the forward air, you'll get the shield to come up afterwards instead of the grab.
Also, as others have said, if you're holding the grab button for too long as well, you'll also end up buffering the shield for the same reasons as said in this post.
To get grabs after moves more consistently, train yourself to press the grab button after the lag of the move has worn off or intentionally buffer the shield with the trigger buttons (L/R) and mash a to get the grab out as fast as possible (aka the regular shield grab).
At least I this is what I think is happening. I haven't played/studied Brawl in a while, so I'm probably wrong in everything I said.