If Williams shoved a player with two hands, he wouldn't get ejected. The rule is nuanced enough and gives the refs enough leeway to apply some judgment to it. And in that instance, the official who was shoved believed Williams was party of a melee and shoved him out of the way likely thinking it was another player.
The intent of the rule is to prevent players from shoving, hitting, tackling refs out of frustration over calls, etc. That's not what happened there.
Again, if there is a scrum on the field and an official tries to pull off a guy and that guy gets up angrily and knocks over the ref, he's likely not going to be ejected. Because a good ref will understand the situation and realize that the player wasn't intending to knock a ref on his ass, probably like how the ref assumed Williams didn't realize he was shoving an official.
And one more point, Williams may have been a punk in the first half, but he was met, or exceeded, by quite a few 49ers players when it came to jawing, pushing, etc. And I say that as someone who didn't want the Ravens to win simply because I didn't want Ray Lewis to go out a winner.