Why does Citric Acid occur in Citrus fruits?
Actually citric acid is not only available in citrus fruit but also in pretty much any living thing. it is an important intermediate in Krebs cycle, but I guess the main reason that it is available in high concentrations in citrus fruits is because citrate is an inhibitory compound for phosphofructokinase, that means it stops the glycolysis and hence it makes it hard for bacteria to use the fructose available in the fruit body.

Source:
 Stryer, Lubert; Berg, Jeremy; Tymoczko, John (2003). "Section 16.2: The Glycolytic Pathway Is Tightly Controlled". Biochemistry (5. ed., international ed., 3. printing ed.). New York: Freeman. ISBN 978-0716746843.