When we plot variable in Euclidean Space, why is it that the variable that are independent of each other, like x-coordinate, y-coordinate, lie on axes perpendicular to the other?
*** Edit: How do we know that projection of a quantity is equal to cos $\theta and nothing else?
Is it an axiom or something like that?
Thirdly, does that work even in other geometries?
The motive for orthogonal axes is to construct a basis. If $\vec{X}=\sum_j X_j \vec{e}_j$ with $\vec{e}_j\cdot\vec{e}_k=\delta_{jk}$ (i.e. $1$ if $j=k$ or $0$ otherwise), $X_k=\vec{e}_k\cdot\vec{X}$ is unique. And since dot products scale as $\cos\theta=0$, our requirement is that the $\vec{e}_j$ are orthogonal.
But where, you asked, does the cosine come from? You can interpret vectors as matrices. The dot product of two vectors is the entry of a $1\times 1$ matrix $X^T Y$. If I multiply each vector on the left by a square matrix $R$, this result becomes $X^T R^T RY$. Rotations satisfy $R^T R=I$, leaving the dot product unchanged. Therefore we may as well assume one vector runs along the positive $x$-axis and other within the $xy$-plane, and then the dot product is just $XY\cos\theta$ by trigonometry.