A lovely example of this is the germination rooms/tanks of malting plants where Barley gets germinated over a few days (2-3) before being dried/kilned to make brewing malt: they all have an on-going battle against fungi and algae, much of which battle takes the form of fungicides/algacides, chlorine washes, strong acids, etc. and they never "win" a permanent victory.
The answer, my friend, is blowin' in the wind...
Same for fungi: it’s usually brought, or becomes endemic, in with the soil.
Things are a bit cleaner in vertical plant farms as long as they dont use animal biproducts in their process.
And again: why bother? Market gardens are highly space efficient and can feed hundreds of people from the space normally occupied by a suburban house plot. Locating a market garden outside an agglomeration and transporting the produce an hour or so into the city is also very practical. And of course actual staple crops are shelf stable and can thus be transported anywhere at leisure. This fancy "vertical farming" stuff makes sense on a space station and desert cities flush with petro dollars but that's about it.
There are edge cases where the technology developed for vertical farms seems very useful: densely-populated, small countries; space stations, and off-world colonies. But for most of Earth? Look at how much of the US is farmland, and then imagine how many expensive towers and associated infrastructure you'd need to replace it.
The biggest advantage of indoor farming is that you no longer need to use chemical pesticides and herbicides.