In the original version, you have many separate sections that each say something like:
If this input combination happens, turn some outputs on.
Otherwise, turn all outputs off.
Even if one code section matches, all the other sections that do not match will do the "turn everything off" part, writing zero to the port.
The outputs can never stay set, no matter what the inputs are.
The modified version looks for each possible input combination and only turns the outputs off (with portb = 0; ) if none of the match lines are valid.