How can it be that my ankle keeps giving way?

Many causes. They range from stretched out or torn ankle ligaments (usually laterally) to nerve problems causing weakness of the muscle that prevent your ankle from twisting the tendon ruptures/problems. In addition bone structure problems such as tarsal coalitions or varus deformities of the hind foot. Sometimes just unrehabilitated muscle strength with loss of proprioception. Get evaluated to sort it out.
Weak ligaments. If you have a history of sprains or even if you dont the ligaments may be weak. Important to evaluate the cause and consider bracing and a course of physical therapy. See your local foot and ankle specialist.
You have. Chronic lateral ankle instability. You can wear a brace to help prevent further sprains or have it corrected surgically. Therapy may help too.