What you are saying is not entirely correct.
- That equation for $K_f^2$ is not a definition. It's a consequence of the definition of $K_f$ as $K_X-f^*K_B$: If $F$ denotes a fiber of $f$, then since $K_X\cdot F=\deg K_F = 2g-2$,
$$
K_f^2 = K_X^2 - 2 K_X\cdot f^*K_B = K_X^2 - 2 K_X\cdot (2g(b)-2) F = K_X^2 - 2(2g-2)(2g(B)-2).
$$
- The statement you are looking for is not exactly like that. $K_f^2=0$ is not equivalent to $f$ being locally trivial, but being generically locally trivial. That is, for instance it might have some singular fibers, but the smooth fibers are isomorphic. The right word actually is isotrivial, which is defined as two general fibers being isomorphic.
With that said, Vesselin already gave you the correct reference, but at the same time there is a whole lot of newer results that deal with these kind of questions.
The modern approach is that first of all regardless of any assumption on isotriviality, the sheaf $f_*\mathscr O_X(mK_{f})$ is semipositive for large and divisible enough $m$. Then using the fact that the fibers are canonically polarized varieties (that's the real reason you need $g\geq 2$), the natural map
$$f^*f_*\mathscr O_X(mK_{f})\to \mathscr O_X(mK_{f})$$ is generically surjective, so with a bit of work you can prove that $K_f$ is nef and then $K_f^2\geq 0$ always and then $K_f^2> 0$ if and only if $K_f=K_{X/B}$ is big. That last condition follows from 3.2 in Arakelov's paper as Vesselin already mentioned. (By the way, that result is for a stable model of $f$ which is not necessarily smooth, but everything works out at the end).
The advantage of this approach is that this works in higher dimensions as well.