Your post is about encountering municipal bureaucracy when you had it in mind to do it yourself in the first place.
I'm no fan of bureaucracy for its own sake. But there's a reason you need to jump through some hoops when you want to change something on your property. Those trees you want to cut down might be crucial for flood mitigation. That room you want to turn into a spare bedroom might be a fire-trap if it lacks a window or quick access to an exit route. Digging on your property might disrupt buried pipes or cables.
Like it or not, we do need rules, even though sometimes they may seem silly to you.
Oddly, I don't think that's ever been an issue because DIY is happening all the time, and that's why those regulations are there because someone dies and people find out it's because an unauthorized renovation happened that created a firetrap.
So no, it's not a deterrent because it's happening all the time. It's made worse by house flippers because those people are cutting corners to save money (i.e., make more profit), who you know aren't taking time to get permits, do inspections, or even bring things to code. By the time the flawed renovations are discovered, it's too late and the buyer is basically left with their house falling to pieces.
So I don't get get the claptrap that DIY is illegal - because if it was illegal, substandard construction and renovation work wouldn't be happening. There's probably a small fraction of the unpermitted work done properly to code (or better - remember code is just a minimum) and you'll never know until decades down the line when someone tries to renovate and discovers no permit was ever taken out. It's just it was well constructed, well built that no one needed to do anything. But that is far from the norm, and DIYers are basically the reason for the regulatory hell.
Also why "house flipping" should be an immediate rejection of a house - it looks pretty but the pain is likely concealing a load of issues you won't find out until later.
For Africa, the situation is different. The government led projects aren't happening not because of regulations, but because corruption and other things are basically draining the resources. Building an electric grid even without regulations we have (basically it's the wild west outside of Western nations) still costs money and effort, and enough palms get greased that no money makes it down to do the work. That's why it's not happening. And having electricity is better than not, so even the shadiest and lousiest of DIY gear you can get off Temu makes your life way better than trying to get it done the right way. Electrification rates in Africa are disputed because if you have a house with a single LED light that provides light for a few hours after dark, you're considered to have electricity.
Even the most basic DIY solar projects in Africa provide that, but also power to charge cellphones and provide Internet connectivity (during the day - there are batteries but they provide the lighting) - when the sun is out the battery charges and runs an inverter so you can run a computer to get Internet (usually via cellular network). This is often enough for farmers to access trading networks and get weather forecasts which is why it exists and is considered an important resource. And while the sun is out, cellphone charging is done.