How does the axiom of regularity forbid self containing sets?

Let $A$ be any set. Then $\{A\}$ is a set, and by regularity $\{A\}$ must contain an element disjoint from $\{A\}$. The only element of $\{A\}$ is $A$, so $A\cap\{A\}=\varnothing$, and it follows immediately that $A\notin A$.


No. The axiom of regularity says this: every non-empty set contains an element disjoint from it. So suppose there were a set $B$ such that $B = \{ B, \emptyset \}$; then the set $\{ B \}$ contains no element disjoint from $\{ B \}$: $$B \cap \{ B \} = \{ B \} \ne \emptyset$$ so there is no such set $B$.


The axiom of foundation or regularity alone can not show that there is no $x$ such that $x \in x$.

The axiom of regularity (also called the axiom of foundation) asserts that every set has a $\in$ minimal element. That is, for all $x$, there exists a $y \in x$ such that there are no $z \in x$ with $z \in y$.

The axiom of foundation is not exactly equivalent to the fact that there does not exists an $x$ such that $x \notin x$. There is a two element model of foundation (extensional, union, and pairing) such that there exists a $x$ with $x \in x$. Let $M = \{x,y\}$ where $x$ and $y$ two different objects. Define $\in^\mathcal{M} = \{(x,y), (y,y)\}$. You can verify foundation holds in this model $\mathcal{M}$, but $y \in y$.

Note that the axiom of comprehension and foundation can show that there is no $x$ such that $x \in x$