Foul Smell in a fish tank is an indication of poor maintenance. The smell in the fish tank is caused due to ammonia. This indicates that the biological filter is not working or that the fish tank is overloaded (Excess bioload).
Periodic partial water changes ensure that the ammonia and other wastes are removed. If water changes are not done in time, your tank will smell bad.
Fish Tank smell can also indicate death of fish. Sometimes, fish can die in places which are not easy to see, behind filters or plants. Decomposing fish cause a spike in the ammonia level causing the smell.
Overload of the aquarium with more fish than it can handle is also a reason for the tank to smell.
Sometimes, the nitrifying bacteria which provide biological filtration can be killed by medication used to treat disease. This causes the ammonia levels to spike causing the smell.