This type of anemia occurs when the body does not have enough vitamin B12 or folic acid to produce enough red blood cells.