Is there a way of proving that $\mathbb{Z}[i]$ and $\mathbb{Z}[\sqrt{-2}]$ are UFD s without showing that they are euclidian domains? What are direct methods for proving that a ring is a UFD in general without proving that it's a PID/Euclidean domain/field and using the fact that all those things are UFDs?

As an example, we can take $\mathbb{Z}[i]$ or $\mathbb{Z}[\sqrt{-2}]$ or other rings you come up with.
Here are some thoughts:


Exsitence is easy to prove using induction on the norm.
Uniqueness is the hard part, especially since it fails for most rings of the form $\mathbb Z[\sqrt d]$. For the rings you've mentioned, it can be proved by knowing the units and exactly how primes in $\mathbb Z$ decompose in $\mathbb Z[\sqrt d]$. There are three possibilities for a prime $p$: it remains prime, it is product of two non associate primes, it is a square. For the rings you've mentioned, this can be decided in ad hoc ways.


In the general case of the ring of integers in quadratic fields $\mathbb{Q}(\sqrt{n})$, the answer is not simple but is fascinating, See the book Primes of the Form $x^2+ny^2$, by David Cox.
This would be extremely wasteful, and nobody would do it before showing they were Euclidean domains or PIDs, but you could show that they have class number 1 through some indirect means. $\mathbb Z[i]$ is a Dedekind domain so it is a UFD if and only if its class number is 1.