Suppose for a contradiction that $\sqrt{3}$ is rational. Thus $\sqrt{3} = \frac{a}{b}$ where $a, b \in \mathbb{N}$ \ {$0$} and $gcd(a,b) = 1$.
$\sqrt{3} = \frac{a}{b} \Rightarrow 3 = \frac{a^2}{b^2} \Rightarrow a^2 = 3b^2: (1)$
By assumption $gcd(a,b) = 1$, thus $b^2\nmid a^2$ as $gcd(a^2,b^2) = 1$, thus $3 \lvert a^2$ thus $3|a$. Thus $a=3k$ for some $k \in \mathbb{N}$ / {$0$}.
Substituting $a=3k$ into (1):
$3b^2 = (3k)^2 \Rightarrow 9k^2 = 3b^2 \Rightarrow b^2 = 3k^2$.
$k^2 \nmid b^2$ as $k^2 \lvert a^2$ and $gcd(a^2,b^2) = 1$ from $gcd(a,b) = 1$ so if hypothetically $k^2 \lvert a^2$ then $gcd(a^2,b^2) \neq 1$ which is impossible by assumption that $gcd(a,b) = 1$. Thus $3 \lvert b^2$. Thus $3 \lvert b$. $3 \lvert b$ and $3 \lvert a$, but by assumption $gcd(a,b) = 1$, thus this is a contraction. Thus $\sqrt{3}$ is irrational.