What you're describing is the cunning, baffling and powerful aspect of addiction. Unfortunately there really is no understanding it. Believe me, I've tried. I can only accept completely that I am alcoholic and surrender to the fact that I cannot drink normally, ever. I do this one day at a time...and how AA does that all sound? But its true.
A commitment to quit, a plan for detox (if necessary) and daily plan to stay sober is the only way for me. People talk a lot about a 'plan'. For me that simply means setting my intent each day to not drink. Going to some kind of F2F support 3 times a week, counseling if necessary (I've already done A LOT of that), coming here as much as possible, journaling my thoughts and my feelings, engaging in healthy lifestyle stuff (eating right, hydrating, exercise, gardening, hiking). Making a list each day of all the things I'm going to do and using that list, checking off each positive action as I take.
The biggest part, do not drink today, no matter what. It takes effort and thought. Forcing myself to think in a manner that is uplifting, not in a manner that is self defeating. You can do this!