Axiom of Regularity allows for this set be an element of itself I'm new to set theory, and the axiom of regularity has been giving me some trouble. It states that every non-empty set A has an element B such that A and B are disjoint sets. Apparently, this axiom implies that a set can't be an element of itself. I've heard (and agree with) arguments like this:

Let A be a set, and apply the axiom of regularity to {A}, which is a set by the axiom of pairing. We see that there must be an element of {A} which is disjoint from {A}. Since the only element of {A} is A, it must be that A is disjoint from {A}. So, since A ∈ {A}, we cannot have A ∈ A (by the definition of disjoint).

However, let's say there's a set A = {{1, 2}, A}. It seems like this set obeys the axiom of regularity, because {1, 2} is an element of A, and {1,2} and A are disjoint sets. However, the axiom of regularity shouldn't allow A to be an element of itself. I suppose there's a flaw in my logic somewhere, and I'm hoping someone knowledgeable can show me why this isn't allowed.
Just because a set appears to obey the axiom of regularity doesn't mean it actually is a set!  The axiom of regularity restricts what sets exist: if a non-empty set exists, then it has an element that is disjoint from it.  The axiom of regularity doesn't say that any putative collection which follows this rule has to actually exist as a set.

So, all you have observed is that if a set $A=\{\{1,2\},A\}$ existed, then $A$ would not be a counterexample to the axiom of regularity.  This in no way proves that such a set actually exists!  And in fact, if such a set did exist, then $\{A\}$ would be a counterexample to the axiom of regularity.  This is a contradiction, and therefore no such set $A$ exists.
I'm actually not very familiar with set theory, but I think I see the issue here: when working with set theory, you adopt a certain definition of "set", which entails some mathematical rules (including the axiom of regularity) that any object has to satisfy in order to be a set. An object $A$ which satisfies $A = \{\{1,2\}, A\}$ may "exist" (whatever that means), but it does not satisfy the rules of "set-hood", and therefore is not a set. Just because the notation you use to define it looks set-like, that doesn't make it a set.

I could probably make a rough analogy to the "number" $0.00\ldots1$, which is written using basically the same notation as many things which are numbers, but does not actually satisfy the rules of "number-hood".

You might also find it useful to read Define $A = \{ 1,2,A \}$, $A$ can not be a set (Axiom of regularity). Can $A$ be a &quot;class&quot; or a &quot;collection&quot; of elements., e.g. Asaf Karagila's answer which points out that the definition $A = \{\{1,2\}, A\}$ is circular. Depending on your frame of mind that might make more sense than what I've said above.