Its great that you aware of things like that and are questioning your motives behind them. Dig a little deeper and see what's behind those urges. I usually found that it was some fear-based belief driving some of my actions.
At first I would notice this way after the fact and reflect like u did up there^^^^. Then I would realize it shortly after it happened. I worked towards recognizing it in the moment and making the concious decision to not do or believe certain things.