Grout is porous which allows water to sit and grow mold. You need to use a grout sealing product.
Example:
https://www.homedepot.com/p/Custom-Building-Products-Aqua-Mix-Sealer-s-Choice-Gold-24-oz-Penetrating-Sealer-AMSC24Z/202907686
After cleaning your grout, you can use a product that will soak in to the grout and seal it from water entering. You should do this about once a year to prevent mold.
Use a foam brush and/or grout sealer applicator to apply it on cleaned grout. Do a second coat within 30 minutes to an hour or so (follow the product directions). Foam brushes are easer on wall grout IMHO.
To test after sealer dries, take a drop of water and put it on the grout. If it soaks it in, you need more sealer. If it beads on top or rolls past it, your good to go!
Sealing grout is an easy win in home care! Make sure you have good ventilation when using these products as they have a lot of VOCs!