That is because the chemical reactivity of $^{18}\text{O}$ is slightly higher than that of $^{16}\text{O}$. For that reason, the biochemical reactions that produce calcium carbonate in foraminifera prefer $^{18}\text{O}$ over $^{16}\text{O}$.
However, the temperature dependence arise from the fact that the difference in reactivity is smaller when temperature increase. Therefore, in warmer temperatures the $\delta ^{18}\text{O}$ will be more similar to seawater (no preference for any isotope), but at colder temperatures the chemical preference for $^{18}\text{O}$ will be stronger and, therefore, the $\delta ^{18}\text{O}$ will increase.
This correlation with temperature is also known as the "paleotemperature equation", but as it is an empiric equation there are many slightly different versions, however all of them are pretty consistent. Several ones are summarized in figure 5 of the paper Oxygen isotopes in foraminifera: Overview and historical review (Pearson 2012) copied below, showing how the excess of $\delta ^{18}\text{O}$ in shells ($\delta ^{18}\text{O}_{\text{cc}}$) relative to the $\delta ^{18}\text{O}$ in seawater ($\delta ^{18}\text{O}_{\text{sw}}$) correlates with water temperature.
The deeper reason that explain the chemical preference for $^{18}\text{O}$ come from a process named "equilibrium isotope fractionation", associated to the vibrational characteristics of the light and heavy isotopes related to covalent atomic bonding.
As explained by Gussone et. al (2003):
"Equilibrium fractionation occurs as a consequence of covalent atomic
bonding. During molecule formation the incorporation of heavier
isotopes is preferred because covalent atomic bonds formed with
heavier isotopes show larger bonding energies and, hence, are more
stable than covalent bonds formed with lighter isotopes."
There is a competing effect called "kinetic isotope fractionation", that that leads to a correlation with temperature in the opposite direction (because heavier isotopes have slower diffusion times and are slower crossing membranes), but in the case of Oxygen isotopes, its effects is overcome by equilibrium fractionation.