This is the method I have taught students I have tutored on how to factor quadratics.
Consider the general quadratic:
$\displaystyle ax^2+bx+c$
In the case of $\displaystyle x^2-2x+1=(1)x^2+(-2)x+(1)$, we identify:
$a=1,\,b=-2,\,c=1$
To factor, I first look at the product $ac=(1)(1)=1$. We want to find two factors of 1 whose sum is $b=-1$, and so those factors are -1 and -1, since $(-1)(-1)=1$ and $(-1)+(-1)=-2$.
Since $a=1$, we know the factorization will be of the form:
$(x\cdots)(x\cdots)$
To understand why the method I outlined works, we could set:
$x^2-2x+1=(x+d)(x+e)=x^2+(d+e)x+de$
Equating coefficients, we see we need two numbers $d$ and $e$ that simultaneously satisfy:
$d+e=-2$
$de=1$
As we already found, we need $d=e=-1$.
And so we may replace the dots with the two factors we found:
$(x-1)(x-1)=(x-1)^2$
Thus, we may state:
$x^2-2x+1=(x-1)^2$
The method I outlined can get a little more involved if $a$ is not 1, even more involved still if $a$ is a composite number. Consider the quadratic:
$8x^2+34x+35$
We want two factors of $8\cdot35=280$ whose sum is $34$. They are $14$ and $20$. Now we must observe that $20$ is divisible by $4$ and $14$ is divisible by $2$. The product of $2$ and $4$ will give is $a=8$.
So, we will have the form:
$(4x\cdots)(2x\cdots)$
$\displaystyle \frac{20}{4}=5$ and $\displaystyle \frac{14}{2}=7$ so we have:
$8x^2+34x+35=(4x+7)(2x+5)$