Sadly I have some personal experience of a very close family member who was an alcoholic, it killed him in the end but he was a (more or less, often less) functioning alcoholic for many many years. I agree with trying to set some boundaries and protect yourself, it is incredibly difficult living with or caring for someone in this situation, maybe take a look at the Al-Anon (charity for relatives and loved ones of alcoholics) resources and see if they have a group near you - it's comforting just knowing you aren't alone.
In terms of the question you ask about 'why' people continue to drink despite it being increasingly obvious how damaging it is, in every way, including to those around them. I think in the gentlest possible way you're looking at it slightly too simplistically, there isn't a straightforward answer. People don't become alcoholics overnight and nor is it as simple as just because on some occasions they can be sober, they can always be sober if they just tried harder/cared more. You absolutely can't allow yourself to think that if only you persuaded your person hard enough, if you can just find the right words or if only they loved you enough they'd change - down that road I'm afraid madness and a huge amount of guilt and anxiety on your part lies so turn around now if you can. It's a hard thing to accept but step 1 is understanding that you cannot talk someone out of their alcoholism (you didn't create this, you can't control it, you won't cure it, al-anon mantra).
In my experience alcoholism is nearly always a response/consequence of complex other factors going on in the person's life, so in my relative's case it almost certainly started with undiagnosed and unsupported neuro-diversity from childhood, leading to quite complex mental health issues. Alcohol started as a useful way of self-medicating and way of coping with the things in his life he found hard, which then spiralled from there. There was also had some inter-generational trauma (to use a trendy phrase), we have a long long family history of mental instability and alcoholism, he himself was the child of two alcoholics, probably again something to do with neurodiversity as there's such a genetic component to that plus the fact that if you're shown maladaptive social patterns and coping mechanisms from early childhood of course you are at risk of repeating that in your own life. Then there are the social issues and the vicious circle of addiction, as the alcoholic goes deeper and deeper in, the worse the consequences i.e. relationship breakdown, job loss and unemployment, poor physical health, alienation of friends and wider family, terrible finances, even homelessness (my relative again followed this sad but well-trodden downwards cycle) - the more all this goes on the less attractive an option sobriety can seem and the more attractive blocking it all out with alcohol is. Most alcoholics (unsurprisingly given alcohol is a depressant) are chronically depressed and feel a lot of shame about themselves, terribly low self-esteem and a feeling of hopelessness and despair about the future. Not a great foundation for starting off a difficult task of quitting - possible of course but needs a huge effort on the part of the person which sadly not everyone has in them if they've been repeatedly bashed around by life.
I hope that little bit of insight might help, ultimately I don't find thinking about the 'why' too much is all that helpful, TLDR = it's complex , alcoholics aren't necessarily bad people but nor are they saints, personally I found the only way through was setting and being clear about my own boundaries and doing what I needed to do to protect myself and my kids, not trying to control the alcohol per se but offering what support I could. There's no right or wrong way through this sad process though. The alcohol support board here is a good resource, people have walked this road before and that can be a comforting thing if nothing else is?