I would emphasize the idea about repeated roots. A polynomial over, say, the integers, but with roots considered in $\mathbb C,$ has repeated roots under very specific conditions, and that can be used; for each real root $\alpha,$ we know that $(x-\alpha)$ divides $f(x)$ to degree at least 2, so it divides the derivative to at least degree 1. With a complex root $\beta,$ same fact for the product $(x - \beta)(x - \bar{\beta}).$
As a result, if there is a square root $s(x),$ then
$$ s(x) | \gcd(f(x), f'(x)). $$ The magical part is that the $\gcd$ has integer coefficients and the top degree coefficient can be forced to be 1.
I would say that this idea does not help with general factoring, but is definitive for squares: we can either say that the polynomial is not a perfect square or find the square root.
Pausing...
Here, taking $f(x) = x^4 + 6 x^3 + 7 x^2 - 6 x + 1,$ with $f'(x) = 4 x^3 + 18 x^2 + 14 x,$ and $g = \gcd(f(x), f'(x)),$ we get
$$ g | h = (4f - x f') = 6 x^3 +14 x^2 - 18 x + 4. $$
Then
$$ g | (3f' - 2 h) = 26 x^2 + 76 x + -26 = 26 (x^2 + 3 x - 1). $$
And that works.
Next: higher (even) powers involved
I made up an example; I am hoping to show that one may address this question with two operations, taking formal derivative of polynomials, and taking gcd of two polynomials.
$$ f = x^8 - 10 x^7 + 35 x^6 - 56 x^5 + 91 x^4 - 210 x^3 + 189 x^2 - 108 x + 324 $$
$$ f' = 8 x^7 - 70 x^6 + 210x^5 - 280x^4 + 364x^3 - 630x^2 + 378x - 108 $$
$$ g_{01} = \gcd(f,f') = x^5 - 8 x^4 + 20x^3 - 18x^2 + 27x - 54 $$
how to find gcd:
====================================
$$ \left( x^{8} - 10 x^{7} + 35 x^{6} - 56 x^{5} + 91 x^{4} - 210 x^{3} + 189 x^{2} - 108 x + 324 \right) $$
$$ \left( 4 x^{7} - 35 x^{6} + 105 x^{5} - 140 x^{4} + 182 x^{3} - 315 x^{2} + 189 x - 54 \right) $$
$$ \left( x^{8} - 10 x^{7} + 35 x^{6} - 56 x^{5} + 91 x^{4} - 210 x^{3} + 189 x^{2} - 108 x + 324 \right) = \left( 4 x^{7} - 35 x^{6} + 105 x^{5} - 140 x^{4} + 182 x^{3} - 315 x^{2} + 189 x - 54 \right) \cdot \color{magenta}{ \left( \frac{ 4 x - 5 }{ 16 } \right) } + \left( \frac{ - 35 x^{6} + 189 x^{5} + 28 x^{4} - 1190 x^{3} + 693 x^{2} - 567 x + 4914 }{ 16 } \right) $$
$$ \left( 4 x^{7} - 35 x^{6} + 105 x^{5} - 140 x^{4} + 182 x^{3} - 315 x^{2} + 189 x - 54 \right) = \left( \frac{ - 35 x^{6} + 189 x^{5} + 28 x^{4} - 1190 x^{3} + 693 x^{2} - 567 x + 4914 }{ 16 } \right) \cdot \color{magenta}{ \left( \frac{ - 320 x + 1072 }{ 175 } \right) } + \left( \frac{ 896 x^{5} - 7168 x^{4} + 17920 x^{3} - 16128 x^{2} + 24192 x - 48384 }{ 25 } \right) $$
$$ \left( \frac{ - 35 x^{6} + 189 x^{5} + 28 x^{4} - 1190 x^{3} + 693 x^{2} - 567 x + 4914 }{ 16 } \right) = \left( \frac{ 896 x^{5} - 7168 x^{4} + 17920 x^{3} - 16128 x^{2} + 24192 x - 48384 }{ 25 } \right) \cdot \color{magenta}{ \left( \frac{ - 125 x - 325 }{ 2048 } \right) } + \left( 0 \right) $$
$$ \frac{ 0}{1} $$
$$ \frac{ 1}{0} $$
$$ \color{magenta}{ \left( \frac{ 4 x - 5 }{ 16 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ 4 x - 5 }{ 16 } \right) }{ \left( 1 \right) } $$
$$ \color{magenta}{ \left( \frac{ - 320 x + 1072 }{ 175 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ - 80 x^{2} + 368 x - 160 }{ 175 } \right) }{ \left( \frac{ - 320 x + 1072 }{ 175 } \right) } $$
$$ \color{magenta}{ \left( \frac{ - 125 x - 325 }{ 2048 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ 25 x^{3} - 50 x^{2} - 25 x - 150 }{ 896 } \right) }{ \left( \frac{ 100 x^{2} - 75 x + 25 }{ 896 } \right) } $$
$$ \left( x^{3} - 2 x^{2} - x - 6 \right) \left( \frac{ - 20 x + 67 }{ 392 } \right) - \left( 4 x^{2} - 3 x + 1 \right) \left( \frac{ - 5 x^{2} + 23 x - 10 }{ 392 } \right) = \left( -1 \right) $$
$$ \left( x^{8} - 10 x^{7} + 35 x^{6} - 56 x^{5} + 91 x^{4} - 210 x^{3} + 189 x^{2} - 108 x + 324 \right) = \left( x^{3} - 2 x^{2} - x - 6 \right) \cdot \color{magenta}{ \left( x^{5} - 8 x^{4} + 20 x^{3} - 18 x^{2} + 27 x - 54 \right) } + \left( 0 \right) $$
$$ \left( 4 x^{7} - 35 x^{6} + 105 x^{5} - 140 x^{4} + 182 x^{3} - 315 x^{2} + 189 x - 54 \right) = \left( 4 x^{2} - 3 x + 1 \right) \cdot \color{magenta}{ \left( x^{5} - 8 x^{4} + 20 x^{3} - 18 x^{2} + 27 x - 54 \right) } + \left( 0 \right) $$
$$ \mbox{GCD} = \color{magenta}{ \left( x^{5} - 8 x^{4} + 20 x^{3} - 18 x^{2} + 27 x - 54 \right) } $$
$$ \left( x^{8} - 10 x^{7} + 35 x^{6} - 56 x^{5} + 91 x^{4} - 210 x^{3} + 189 x^{2} - 108 x + 324 \right) \left( \frac{ - 20 x + 67 }{ 392 } \right) - \left( 4 x^{7} - 35 x^{6} + 105 x^{5} - 140 x^{4} + 182 x^{3} - 315 x^{2} + 189 x - 54 \right) \left( \frac{ - 5 x^{2} + 23 x - 10 }{ 392 } \right) = \left( - x^{5} + 8 x^{4} - 20 x^{3} + 18 x^{2} - 27 x + 54 \right) $$
===============================
Now, the degree of $g_{01}$ is 5, more than half of 8, so this is encouraging but says that some exponents are over 2. So we do another two derivatives to check for exponent 4.
$$ f'' = 56x^6 - 420x^5 + 1050x^4 - 1120x^3 + 1092x^2 - 1260x + 378, $$
$$ f''' = 336x^5 - 2100x^4 + 4200x^3 - 3360x^2 + 2184x - 1260, $$
and
$$ g_{23} = \gcd(f'',f''') = 56 x - 168 = 56 (x-3). $$
This works: take
$$ h = f / (x-3)^4 = x^4 + 2x^3 + 5x^2 + 4x + 4, $$
$$ h' = 4x^3 + 6x^2 + 10x + 4, $$
$$ g_h = \gcd(h,h') = x^2 + x + 2. $$
This time, we do get half the degree, and success with $h = (x^2 + x + 2)^2.$ Therefore
$$ f = (x^2 + x + 2)^2 (x-3)^4 $$
On purpose, I wanted to see what happens with no rational roots and no quadratic factors. Example
$$ f= x^{12} - 4x^{10} + 4x^9 + 6x^8 - 12x^7 + 2x^6 + 12x^5 - 11x^4 + 6x^2 - 4x + 1, $$
$$ f' = 12x^{11} - 40x^9 + 36x^8 + 48x^7 - 84x^6 + 12x^5 + 60x^4 - 44x^3 + 12x - 4, $$
$$ g_{01}= \gcd(f,f') = x^9 - 3x^7 + 3x^6 + 3x^5 - 6x^4 + 2x^3 + 3x^2 - 3x + 1. $$
Once again, that is more than half the degree, so we keep going.
$$ f'' = 132x^{10} - 360x^8 + 288x^7 + 336x^6 - 504x^5 + 60x^4 + 240x^3 - 132x^2 + 12, $$
$$ f''' = 1320x^9 - 2880x^7 + 2016x^6 + 2016x^5 - 2520x^4 + 240x^3 + 720x^2 - 264x, $$
$$ g_{23}= \gcd(f'',f''') = 132x^3 - 132x + 132 = 132 ( x^3 - x + 1) . $$
This is exactly one quarter of the original degree, and indeed
$$ f = ( x^3 - x + 1)^4. $$