It seems that squaring appears not only in classical Euclidean geometry, but also in physics and statistics. Not too long ago, 3b1b released a video on where pi comes from in the normal distribution equation. In short, the assumption of the uncorrelatedness of two parameters (in the case of a two-dimensional distribution) leads to the quadratic power of the variable and only to it, which can then be generalized to any number of dimensions (that is, parameters). Pi is needed for unitarity. It seems to me that this is very similar to the reasoning when deriving a Pythagorean metric for an arbitrary number of dimensions!
However, it is not clear where exactly the second degree, and not some other, comes from. It seems that only the Pythagorean metric (and also the Riemannian, but locally it is Pythagorean and flat) is continuous and smooth at any point, any direction, and any scale. R^n can be shifted to any distance and rotated in any plane to any angle without losing all of the above properties. Why squaring? Is there any derivation of this metric ab initio (and, importantly, without any circularities in arguments)?
There are actually examples of other norms where we take the $p$th power. So for example, there exists a space where we could say distance is
$$\|\vec{x}\|=|x_1|+|x_2|+\cdots+|x_n|$$
This kind of norm is called a taxicab norm, and it's sometimes useful to think of the length of something being added up like this. So why $p=2$?
In Euclidean space, we have dot products between two vectors, and that would automatically create the concept of a norm. We could define the norm as being
$$\|\vec{x}\|=\sqrt{\langle \vec{x},\vec{x}\rangle}$$
And by relating the definitions of a norm and a metric, we can create certain definitions about the space that we've created. For example, we can then define angle to be
$$\theta=\arccos\frac{\vec{x}\cdot\vec{y}}{\|\vec{x}\|\|\vec{y}\|}$$
Something like this wouldn't be possible in, say, the taxicab norm, because we wouldn't necessarily have $\left|\frac{\vec{x}\cdot\vec{y}}{\|\vec{x}\|\|\vec{y}\|}\right|\leq 1$.
So it is technically possible to not have $p=2$, but that would require you getting rid of the dot product (or you could keep it and have a very cursed space), and lose having definitions for things like orthogonality.