When units belonging to different formations are selected, Commands tries to make a new formation with them. If they used the same formation template then that'll be used for the new formation. But if they used different templates then we don't know which one to use in the new formation so instead we shouldn't make a formation. (Before rP17166 we defaulted to the "line closed" formation.)
That's fine, except instead of not making a formation, we actually make a formation using the null template. The formation breaks apart after we move again, but it shouldn't form in the first place.