Fish hide for any one or more or the following reasons:
1. They are scared. When they are picked on or if they think any of their tank mates may be a threat, they hide.
2. They are sick in soome way. This means they cannot hold their own in a fight, they cannot compete for food and they feel pporly etc.
3. Sometimes spawning is invloved. They may need to hide eggs, they may be livebearers about to give birth or they may be protective parents guarding offspring. Mouth brooders orfet hide to avoid being harassed.
4. Fighting is not uncommon, especially in groups of fish which have pecking orders. They fight to determine their ranking and often the winner is not willing to let things go, The loser needs to flee and to hide to prevent being further beaten.
5, In some species the males primary reason for living is spawning and they will continually chase and harass females. Males may fight with each other for to get the chance to spawn. This is somewhat related to item #4 behavior.
6. Fish often hide when we first put them into out tank. he have likely been netted, transported poorly fed and generally had their life disrupted. And then they are dumped into a completely new environment. This would be disruptive to almost any animal including us. So the initial reaction is to hide. When this is the case, the fish will usually stop being scared and hiding naturally as it gets used to its new home.
Some of the above are universal such as hiding when sick or put into a new tank while some of the other reasons are more species specific.
When I was working with spawning zebra plecos one of the first things I was taught was that a happy zebra was a hiding zebra. If anybody but the very youngest fish were seen hanging out in the open during the daylight hours, it was a good sign that the fish was sick in some way. That is because plecos tend to hide normally, so being out in the open, the opposite of what we usually expect from these fish, was a sign something was not right.
Over time, by onserving our fish, we should learn what is normal behavior in a tank for any given species. Once we learn this, it is easy to know when a fish is behaving abnormally.