Probably because the check valve in your pump has some grit in it, or simply failed, allowing city water to flow backwards into the water tank IMO.
"pump bad check valve tank filling" --
Many of these threads, and similar ones, are in the Fresh Water Systems forum: https://www.airforums.com/forums/f443/
You should always use an inline RV filter in the hose, both when filling the tank, and when on city water, especially if your water source is from a well.
Turn off the city water, use the tank water, and turn the pump on and off a dozen times or so [with a faucet open] . . . usually the grit will clear out on its own. You may have to replace the check valve or pump if the problem does not resolve itself. You might also want to check all your faucet aerator filters for grit. One bad batch of water, from the back forty, can clog up the works all over.