A fish may swim fast, back and forth, because they are stressed or in discomfort due to illness, parasites, or skin issues caused by poor water quality. This is especially true if the behavior is sudden. Regular swimming back and forth may be part of their natural behavior.