This is a basic feature of the mind: focusing on one thing inhibits competing concepts. Inhibition is what happens when you are angry with someone, and it is harder to remember their good traits: the focus on the annoying traits inhibits positive memories.