well fish produces waste right?
This waste breaks down in the form of AMMONIA, which is toxic.
When a filter runs in a tank,with the increased oxygenation, bacteria will begin to colonize surfaces and the filter media
The first bacteria to grow will consume the Ammonia. They process ammonia into NITRITES which is more toxic than Ammonia.
After Nitrites are produced, a second colony of bacteria will grow. These will consume nitrites. They process the nitrites into NITRATES which are much much less toxic than ammonia or nitrites.
When this happen, the fish tank is "cycled". Meaning that essentially, the tank has a stable colony of bacteria that will process toxins, namely Ammonia into Nitrites into Nitrates. This way, instead of a weekly 100% waterchange, it is only neccessary to do about 25-50% Water change weekly.
However due to surface space limitations, any tank under 5 gallon are hard to cycle. And sometimes it's even harder to maintain a stable cycle in such a small tank.