To add to your point: the roots of South Africa’s energy crisis date back to the early 90s, when the apartheid government was finishing up. Until the late 1980s, the apartheid government were into central planning, price controls and other state interventions (like many other western governments of that era). They started deregulating and privatising in the late 80s, and had already started cutting infrastructure spending by the early 90s.
Thus, throughout the 1970s and 1980s they actually massively overbuilt electricity generation infrastructure. In the early 90s, electrification programmes were being rolled out in black townships to soak up the excess capacity. Of course, this excess capacity came with an opportunity cost, as all central planning tends to do.
With the advent of the ANC government the emphasis switched to paying off South Africa’s national debt (which has largely been incurred by the apartheid government fighting proxy wars against the Soviet Union and Cuba).
Finance minister Trevor Manuel and then-deputy president Thabo Mbeki, who pretty much ran South Africa from 1996 to 2008 continued and expanded the early 90s austerity. The economy actually did well during this period and South Africa was widely lauded internationally for its fiscal responsibility, however infrastructure investment didn’t keep up, as you point out, the public transport network (which the apartheid government misguidedly deregulated and handed to the free market in the form of the minibus taxi industry in the late 80s), the road network and other infrastructure started deteriorating through lack of maintenance and also failed to keep up with demand.
The ANC government attempted to restructure the electricity network in the early 2000s to bring it into line with developments in the rest of the world (creating a market for generation), but by this time Mbeki’s AIDS denialism had cost him a lot of political capital with the left of his party (actually the trade union movement, COSATU in alliance with his party). The bottom line is that it was politically infeasible to restructure the electricity industry (the current government is trying again under duress). So without government build of new generation, and no private sector investment because of the stalled market reforms, demand eventually outstripped supply by 2007 (remember what I said about economic growth being relatively high in that era). Load shedding arrived in late 2007. It was actually a huge surprise when it started, and as you say, we were totally unprepared. The IT industry scrambled to install generators in offices.
With the Soccer World Cup coming up in 2010, Eskom (the government body with a virtual monopoly on electricity supply and generation) ran its fleet hard, and also commissioned two mega coal power stations. Mbeki was replaced by 2009 with Jacob Zuma: Mbeki’s arrogance and his insane AIDS policies having finally done him in. Zuma, was of course, not a technocrat like Mbeki, but embodied some of the worst traits of a politician.
Load shedding actually faded into the background for much of the early 2010s, but by 2015 or so, load shedding returned, as that lack of maintenance because of an electricity fleet that was being run too hard caught up.
The two mega coal power stations have been beset with issues as well.
Eskom, despite recent efforts to clean it up, languished under a cloud of corruption and incompetence through the 2010s as part of a pattern of politically connected incompetents gaining purchase throughout the state. Water woes kicked in by 2014, with large parts of high-altitude Gauteng province without water because the pumps that raised water from dam catchments failed (they were repaired but it was a sign of how badly things were being neglected). There are rumours that hangers on from Zuma’s era are sabotaging Eskom from within…it’s hard to be sure, but regardless, it was left in a sorry state.
South Africa is a constitutional democracy with strong institutions…the fact that it managed to survive the Zuma era without collapsing is a testament to that. However, the ruling ANC is run under the Leninist precepts of Democratic Centralism and thus the president of the ANC has enormous power because of the electoral dominance of the party (you could look to China’s CCP intrigues for an analogue).
Even if Cyril Ramaphosa, the current president, and basically a good egg, manages to push through reforms, it may well be too late. The country could well be in a death spiral.