A bottle of sealed water (bottled water) can last for years and years, maybe never go bad. Actually, it's not the water that goes bad, it's the stuff that grows in it that's bad.
Prolong the life growth of bacteria and such, and water is good ... forever.
How long can you prolong bacteria growth in a holding tank in an RV? That all depends upon the water originally put in the tank, how much bacteria it initially has. And then it depends upon how sealed the tank is. And then it depends upon temperature and environmental conditions. Basically, there is no answer.
A bucket of distilled water left outside uncovered for 2 hours can begin to grow green stuff in it. A gallon of rain water in a vacuum tight sealed container will look OK for years.
Personally, if the camper is not in use, the tanks are emptied. Emptied tanks means one less thing to wrong wrong. Same with the water heater, drain it.
If they are emptied for any great length of time (like 6 months) it's best to sanitize them before using again. Although they are drained, they are still wet inside, and if in hot weather can still grow bacteria, mold, yucky stuff.
If you have access to city water, your water is already treated with an element of chlorine and chemicals. You probably don't need to sanitize after sitting or in use.
Here again, there is no true answer only because everyone's RV is built and designed different, and everyone lives under different environmental elements, and everyone uses different gradients of pure 100% uncontaminated H2O.