So I only have an Algebra II level understanding of math seeing as I am still in high school and am still missing some fundamentals seeing as I didn't pay attention in math until this year. However when recalling something my algebra teacher had taught me during the year I came up with some questions regarding the logic recently.
So during the school year, I was taught that $\frac{2}2=1, \frac{a}a=1, \frac{xy}{xy}=1$ and so forth but $\frac{0}0= \text{Undefined}$... and while researching this topic I found that the algebraic way to write all these fractions is as such $2(x)=2, a(x)=a,$ and $0(x)=0$ and upon researching this further I found that the reason that $\frac00$ is undefined is that for any value of $x$ the equation holds true. However, seeing as in the fraction $\frac{a}a$ $a$ is a variable and variables can represent any given quantity I was wondering in the case that $a=0$ would $\frac{a}a$ still $=1$ and if not why along with the fact that lets say $a=0$ and you didn't know it why is it safe to assume that $a$ would never equal zero? Also if it happens to be the case where when $a=0, \frac{a}a=1$ (which I doubt it is) shouldn't this mean that $\frac{0}0=1$ then?
$$\frac{a}{a} = \begin{cases} 1 & a \neq 0 \\ \text{undefined} & a = 0\end{cases}$$
Strictly speaking, you have to check whether $a$ is zero before you cancel terms off from both numerator or denominator.
Even before we write down $\frac{a}{a}$, we should first check if the denominator can be zero, i.e. check it before we write down such term. (Credit : Sean Roberson)