The algorithm works by progressively improving an estimate of the shortest path between every pair of vertices by considering each vertex as a possible intermediate step on the path. It would be wrong since now you are iterating through all source node for all intermediary node for all target node instead.
However even if you mess up the order of loops it will run correctly if you repeat it 3 times.
Refer to this paper for the proof of that : https://arxiv.org/abs/1904.01210