I'm not an expert, but from memory something which it turns out is called the Brahmagupta–Fibonacci identity or occasionally Diophantus identity (used constructively in the proof of the result of Fermat) might be useful: see Wikipedia.
$$\left(a^2 + b^2\right)\left(c^2 + d^2\right) = \left(ac-bd\right)^2 + \left(ad+bc\right)^2
= \left(ac+bd\right)^2 + \left(ad-bc\right)^2$$
This allows you to strip off factors one at a time.
Where you have squares in the factorization, as in the $5\cdot 11^2$ case, note that the square can be factored out as $(p^2+q^2)m^2 = (pm)^2 + (qm)^2$
This question is answered in "Introduction to Number
Theory" by Niven, Zuckerman& Montmogery (pp.318-319 of
the fifth edition). I summarize their proof below.
Every integer $\geq 34$ is a sum of five positive squares
(while $33$ is not). The number five is optimal, because
the only representation of $2^{2r+1}$ as a sum of four
squares is $0^2+0^2+(2^r)^2+(2^r)^2$ (easy exercice by induction
on $r$).
One can check by hand by noting all the numbers between $34$ and $169$
are sums of five positive squares. Now, let $n\geq 169$ and let us
show that $n$ is a sum of five positive squares.
We know that $n-169$ is a sum of four not necessarily positive
squares, $n-169=x_1^2+x_2^2+x_3^2+x_4^2$ and we can assume
$x_1 \leq x_2 \leq x_3 \leq x_4$.
If $x_1>0$, writing $n=13^2+x_1^2+x_2^2+x_3^2+x_4^2$ we are done. So assume
$x_1=0$.
If $x_2>0$, writing $n=5^2+12^2+x_2^2+x_3^2+x_4^2$ we are done. So assume
$x_2=0$.
If $x_3>0$, writing $n=3^2+4^2+12^2+x_3^2+x_4^2$ we are done. So assume
$x_3=0$.
If $x_4>0$, writing $n=2^2+4^2+7^2+12^2+x_4^2$ we are done. So assume
$x_4=0$.
So now all the $x_i$ are zero, and $n=169=5^2+6^2+6^2+6^2+6^2$. This concludes
the proof.
Best Answer
Similar to the Brahmagupta-Fibonacci two-square identity. Euler has a four square identity which involves the sum of 4 squares:
$$(a_1^2+a_2^2+a_3^2+a_4^2)(b_1^2+b_2^2+b_3^2+b_4^2) =\\ \quad(a_1b_1 - a_2b_2 - a_3b_3 - a_4b_4)^2 + (a_1b_2+a_2b_1+a_3b_4-a_4b_3)^2 +(a_1b_3 - a_2b_4 + a_3b_1 + a_4b_2)^2 + (a_1b_4 + a_2b_3 - a_3b_2 + a_4b_1)^2$$
Factor $1638$ as products of any small factors you know how to represent as sum of 4 squares. Repeat apply the formula will allow you to represent $1638$ itself as sum of 4 squares.
For example, let's say we have factored $1638$ as $2\cdot 3^2 \cdot 7 \cdot 13$, we have:
$$\begin{align} & 2\cdot 3^2 \cdot 7 \cdot 13\\ = & (1^2+1^2+0^2+0^2)(1^2+1^2+1^2+0^2)^2(2^2+1^2+1^2+1^2)(3^2+2^2+0^2+0^2)\\ = & (0^2 + 2^2 + 1^2 + 1^2)(1^2+1^2+1^2+0^2)(2^2+1^2+1^2+1^2)(3^2+2^2+0^2+0^2)\\ = & ((-3)^2 + 1^2 + 2^2 + 2^2)(2^2+1^2+1^2+1^2)(3^2+2^2+0^2+0^2)\\ = & ((-11)^2+(-1)^2+2^2 + 0^2)(3^2+2^2+0^2+0^2)\\ = & ((-31)^2 + (-25)^2 + 6^2 + 4^2)\\ \end{align}$$
This give you a non-trivial representation of $1638$ as $31^2 + 25^2 + 6^2 + 4^2$.
In general, there are many representations of a number as a sum of 4 squares. There is a theorem:
The above representation is only $1$ out of $8 \sum_{d\mid 1638, 4 \nmid d} d = 34944$ ways of representing $1638$ as sum of 4 squares.