"It was him -> it was her" -- both are direct objects (at least as you're using them here--once upon a time the correct English would have been "it was he -> it was she", since the verb "to be" is not a transitive verb, but that seems to have gone out of fashion).
"It is his -> it is hers" -- both are possessives, but they're not directly modifying anything (they refer to "it", but the verb is in between).
"It is his thing -> it is her thing" -- both are possessives, but now they are functioning as direct modifiers of "thing", which is a different usage.
I don't know if there is a fully specified algorithm for determining these things, and even if you got one that worked in English, I don't think it would map very easily to any other language, because English is such a hodgepodge of things cherry picked from various languages over the centuries.