Part of it has to do with the schooling nature of fish. Like birds, fish seem to have this innate orientation ability so that they naturally line up all facing the same direction. My fish do it too, when resting they will all orient in the same direction, usually it is facing the brighest light source, which is the window next to their tank.
My goldfish know where the food is. When they see me, they all rush over to the one corner and crowd that corner, all watching me pick up the food canister. They don't go to where I put the food in, but they all rush to that corner to watch me fix their food cup. When they sleep, they all line up facing the same way.
~~Colesea