This usually happens when they are exploring their surroundings looking for food. Another possible cause of this is if they are living in a tank that is too small for them. You can prevent this from happening by keeping a lid on your aquarium.