It's actually impossible to do this in fewer than 16 transitions if you use only horizontal and vertical transitions, even if your path is allowed to cross itself and/or go out of the box!
Proof: Pick any closed path passing through each square. Extend each transition into a line. Now merge all runs of consecutive identical lines. Now these lines still cover all squares together, and the number of horizontal and vertical lines in the extended path is always equal (and not larger than the number of transitions in the original path), since horizontal and vertical lines alternate.
Assume the path has less than 16 lines, so less than eight horizontal lines. Then there is one row which does not contain a horizontal line. But this row has eight squares, which are necessarily passed over by one vertical line each, so there are at least eight vertical lines, so also eight horizontal lines in contradiction to the assumption.
Hence any axis-aligned path through every square must necessarily have at least 16 transitions.
And here's a non-axis-aligned solution in 15 transitions with self-intersections (14 if you can start somewhere else than the marked square), credit to Sam Loyd: