What happened to Type Theory? For any relation R, it is a theorem of first order logic that:
There does not exist an x such that, for all y, Ryx if and only if ~Ryy.
In symbols:
~ExAy(Ryx <-> ~Ryy)
In set theory (with 'e' for 'member of' and taking R to be the membership relation):
~ExAy(yex <-> ~yey)
That is, there does not exist a set x such that, for all y, y is a member of x if and only if y is not a member of itself.
That is a theorem of set theory, as it is a theorem of first order logic for any R.
But how does set theory ensure that that theorem is not contradicted by having its negation also a theorem of set theory?
That is accomplished by not having axioms that would allow it.
In particular, set theory does not have the axiom schema of unrestricted comprehension (aka 'the axiom schema of comprehension' or 'the axiom schema of naive comprehension'), which is:
If P is a formula in which x does not occur free, then ExAy(yex <-> P).
If we have that schema, then we could take P to be ~yey, and derive Russell's paradox from:
ExAy(yex <-> ~yey).
Instead, Z set theory has the axiom schema of separation (aka 'the axiom schema of specification'). (NBG class theory, has a different but similar approach), which is:
If P is a formula in which x does not occur free, then AzExAy(yex <-> (yez & P)).
That says: If you have a set z, then you can form the subset x of z such that the members of x are all and only those members of z that have property P.
In other words, to use a property to define a set, you can only do it by using that property to make a subset of an already given set.
With P being ~yey, with the axiom schema of separation, we have:
AzExAy(yex <-> (yez & ~yey)).
And that doesn't yield a contradiction.
So set theory does not block Russell's paradox by adopting an axiom to block it. (In general, since the logic is monotonic, one cannot add axioms to block inconsistency.) Instead, set theory avoids Russell's paradox by refraining from having axioms that would allow it.
Note: Pedantically, instead of saying 'set theory ensures', we would say 'as far as we know, set theory ensures', since, as far as we know, set theory is consistent.