Is it possible for flavors to stick with a bag used for BIAB brewing, and for it to transfer them to my next brew? If so, what can I do to avoid it
In practice a nylon bag can become discoloured but it rarely gets so contaminated as to actually affect the flavour of a brew. As long as the bag is cleaned of all debris and thoroughly rinsed it should keep well. It is advisable to soak the bag in water soon after the grain is emptied out. If the bag becomes stained or clogged then soaking in a solution of something like VWP (a commercial brewing sanitiser/detergent) should clean it. Others use Vanish or similar peroxide bleaches. I have seen bags washed in domestic washing machines using standard laundry detergents - but watch out for zips/studs/etc catching and ripping the bag in a mixed wash.
If the bag is all plastic construction it can be soaked in a bucket of hot water, then well rinsed and finally microwaved.