Firstly, aluminum is originally made on-site at hydroelectric plants in inconvenient places. While it is energy intensive, nobody else is competing for that electricity. Cost = price of dam ÷ decades of aluminum production.
Secondly, aluminum recycles really well. Dumb machines can separate and purify it to high levels. The majority of aluminum has been recycled at least twice, amortizing the energy cost over a much larger amount of products.
Thirdly, aluminum is ductile (does not shatter) so containers can be made paper thin, and researchers are constantly devising ways to make it thinner. With recycling and thinness, the original production energy can be amortized over 10-100× more containers than an equal strength of glass.