You are assuming the eggshell changes size, and especially you are assuming that the pores in the shell can change size.
I never thought to look into this before, but a bit of google searching found a paper from 1979 called "The Avian Eggshell-a Resistance Network" by R. G. BOARD
Hopefully this link will work:
https://ami-journals.onlinelibrary.wiley.com/doi/pdf/10.1111/j.1365-2672.1980.tb01230.x
I think this paragraph might be the most relevant:
"The work of Haines & Moran (1941) can be taken as a milestone in our understanding of the factors involved in the initiation of rotting of stored hens’ eggs.They recorded a low incidence of rots in eggs that had been immersed briefly in a bacterial suspension of the same temperature but a high incidence when the eggs were warmer than the suspension. They deduced that a small negative pressure was generated in the latter case because the contraction of the yolk and white was greater than that of the shell. This caused contaminated water to be sucked into the pore canal. Their deduction has met with general acceptance even though experimental verification is still awaited."
Unfortunately, I haven't been able to find the 1941 work that was referenced, so I don't know what it actually said.
Part of the 1979 article talks about ways to get antibiotics into eggs (they wanted to hatch healthy chicks from eggs laid by sick hens), and the author considered that putting eggs in a liquid cooler than the egg was a reasonable way to do this. There is some discussion of other methods too (like making a hole in the shell.)
If all this work was done so many years ago, I am not surprised that it is now viewed as common knowledge, but that does make it harder to find explanations of why it works and how that was learned (because not all things that are "common knowledge" are actually right!)