There are two main species of bacteria which are a part of the nitrogen cycle. The nitrosomonas bacteria convert the ammonia into nitrite. The other species nitrobacter convert the nitrite into nitrates.
Hence, healthy and large colonies of both these beneficial bacteria are essential for the health of an aquarium.
When the aquarium is first started, it takes time for the bacteria to establish themselves. This can be accelerated by a process called cycling where water and gravel from and established aquarium is added to the new tank. This enables the quick growth of the bacteria.
The bacteria take time to grow and hence the tank should not be loaded with fish too quickly. Add a few fish in the beginning. Later when the bacteria colonies have established themselves, more fish can be added.
Once the bacteria have established themselves, it is necessary that they are not killed accidentally. Some fish medication will kill these bacteria. An example is potassium permanganate which is used to fight infections.
Aquarium tanks and filters should also never be washed with soap. Soap can kill these bacteria.