I wondered what the exact definition of equality would be and came across this question: Should this "definition" of set equality be an axiom?. I then proceeded to read the corresponding appendix of Tao's book in which he mentions the following:
Equality is a relation linking two objects $x,y$ of the same type $T$ (e.g. two integers or two matrices, or two vectors, etc.). Given two such objects $x$ and $y$, the statement $x=y$ may be true or may not be true; it depends on the value of $x$ and $y$ and also on how equality is defined for the class of objects under consideration. [...] How equality is defined depends on the class of objects $T$ under consideration, and to some extent is just a matter of definition. However, for the purpose of logic we require that equality obeys the following four axioms of equality: $(1)$ Given any object $x$, we have $x=x$. $(2)$ Given any two objects $x,y$ of the same type, if $x=y$ then $y=x$. $(3)$ Given any three objects of the same type, $x,y$ and $z$, if $x=y$ and $y=z$ then $x=z$. $(4)$ Given any two objects of the same type $x,y$, if $x=y$, then $f(x)=f(y)$ for all functions or operations $f$.
I now wonder, how is this used in practice? If I understand it correctly, equality is not defined explicitly but rather what properties equality should have. However in practice one usually is not given an explicit definition of equality. As far as I understand, one does not define equality explicitly which is justified since only the properties that come from the axioms $(1)-(4)$ are used, meaning no matter what explicit equality is used in practice, I obtain the same results. Further questions I have are the following:
Q$1$: Given a group $G$, what does it mean that for two objects, $g_1,g_2 \in G$, $g_1=g_2$? Are they literally the same object of the underlying set, since a set can only contain an element once? I am really unsure what equality should be here, since $G$ can be any group. (This question should work analogously for sets)
Q$2$: Is there an underlying equality for all classes $T$? If one does not define equality explicitly, one has to ensure that there is at least one notion of equality for all "situations", right? Why is that the case?
Q$3$: Given a function $f:A \to B$ and $a \in A$. Why is it possible to write: Let $b=f(a)$? Is this the case due to axiom $(1)$? Meaning that I could at least write $f(a)=f(a)$ or in other words choose $z$ to be $f(a)$?
Q$4$: Isn't axiom $(4)$ already satisfied due to functions being well defined, meaning in particular that for $a=b$ we have that $f(a)=f(b)$?
In most (maybe all) instances, equality is always taken to be at the set level.
But often in different areas of math, we often want take a more abstract view of objects so you define some kind of equivalence relation (e.g. group isomorphism, homeomorphism between topological spaces, etc) where even when two sets are not identical in the set-theoretic sense, they are equivalent in this new sense we are interested in.
Terrence Tao is being a bit loose with the word 'equality' there. I think 'equivalence' would have been a more precise term to use, but it's not uncommon to hear.
Also, equivalence relations satisfy (1)-(3) so they act like equality (equality is an equivalence relation).