Iron deficiency and pernicious anemia both result from destruction of parietal cells.
Gastritis destroys parietal cells
Parietal cells make two things: intrinsic factor and hydrochloric acid. Gastritis has several possible causes: autoimmune attack, H. pylori, long-term PPI use, or gastric surgery. Regardless of which one is responsible, the damage takes out acid and intrinsic factor production together.
The acid connection is specifically relevant for iron absorption. Food iron is mostly ferric (Fe3+), and stomach acid helps keep it soluble and facilitates its reduction to ferrous (Fe2+), the form DMT1 transporters in the duodenum can absorb. Achlorhydria impairs that process. So even with adequate dietary iron, absorption drops.