How is DIY done so much on 'fixer uppers' in areas where AHJs demand permits and licenses?
I will give you an honest answer and could care less about the upvotes/downvotes.  Just my experience flipping houses in many US areas and even some overseas over 25 years.


First every municipality will have a detailed list of things they require a permit for.  


almost all places require you to pull a permit for electrical
if you pull an electrical permit some places will allow you to do some electrical work.  This may or may not include you needing to pass a local electrical permit exam.  I have done so numerous times. 
when applying for a permit most places will take in a percentage (often capped) of the renovations to help offset the costs for their inspection process.

If you are doing a lot of work talk to your inspector.  If you can actually get the inspector at your city hall (or where ever) please talk to him.  Give him an overview of what you may do.  And here is why.  80% of the inspectors are GREAT guys that will help you out and downright give you great advice through the inspection/permit process.  They will tell you that you don't need to pull permits for certain things and give you hints how to pass quicker for other things.   The other 20% of the inspectors... WOW.  They have their buddy Johnny the Electrician and if you don't use Johnny then your guy better be perfect (and perfect means whatever the inspector wants).  Johnny will charge 50% more.  The same goes for all trades.  Or you get the inspector who wants everything permitted - yes I have had an inspector ask me to pull a permit for putting in carpet no kidding.   My point is know what you are dealing with.  If I am dealing with a shady inspector, no way in hell I am pulling permits unless it is for something I know I need to.  That is just the truth.  We may just skip certain renovations because of this.
Don't let #2 fool you I am a pro-permit person.  But permits and passing permits mean nothing.  I can pretty much have any architect write something up and install a beam or whatever and most inspectors will just sign off on anything.  Sure there are inspectors that know their crap... but I am talking about the majority.  Pulling a permit doesn't ensure that the job is done right.  It just ensures that someone looked at it.   I have bought many houses that passed "inspections" that were not done to code, took these to the city and had no recourse.  In one case the city made me repull permits (costing over 5k) because their inspectors passed them incorrectly.  Anyway sued city and they paid for the work done in the end but took 6 months so I was eating mortgage.  My point is here the permit is just another check, not the all being/knowing check.  
When talking electrical.  I will pull a permit if I have a licensed electrician doing work, if I am doing work licensed in the area, or if the work is major.  I will not pull permits for switching out outlets (some cities ask you to pull permits for this - I do not ask as once you ask, you are pulling a permit), I will not pull a permit for adding an extra outlet or two to an existing circuit (yes I follow load standards), and will not pull a permit for switching out aluminum for copper.   
When talking infrastructure... I will pull permit if I am making a modification that is substantial or will impact the house listing - adding bathrooms, bedrooms, square footage.  I used to pull for foundation work... But I found that some cities had practices and outdated information that were making my repairs worse and more costly.   I have trusted pros doing this work for me and trust their opinions more than an inspector who is getting his info from the local foundation guy (who wants all the business so often does unwarranted things at a house and acts like his way is the only way to meet code).  On the other end, I am not pulling a permit to enclose a closet, to shorten or modifying non-loadbearing walls, just not happening.


What are the risks?   Well none really if you do the work correctly.  If you are afraid work is done incorrectly you could be liable for failings but really when houses are sold they are sold as is.  Almost impossible to sue a former house owner.  Probably the biggest risk is that when selling the house you did work that shows up on the comp sheet and word gets back to city (this is not common).   City then could come out and ask for permits.  But the city would have to prove that YOU (not previous owners) made the changes unless they are for unpermitted space.  

Also a good home inspector should be able to see bad work and then the work would have to be redone.   If substantial you would have to pull permits as home inspector may ask city for them.

To conclude, someone could write a book about your question in the US.   I have had so many inspectors tell me "you don't want to pull a permit for that".  I have had so many inspectors tell me to pull permits for the dumbest crap.   (funny example - had to pull permit for changing out tile in kitchen.  Inspector comes out.  He is new and just some random dude with a sheet to checkmark.  He goes through some other stuff we were doing, he asks if tile was done, one of my guys thought he was talking about the bathroom which was done, my guy says yes, he inspects kitchen tile which is about 40 years old, says good, checked, done).  Any homeowner getting work done on their house for roof, electric, plumbing, or major infrastructure should get a permit to help protect themselves.  

Edit: Since it has tag DIY vs pro.  In most areas the only times you would need a pro is an architect for load bearing changes or new space or electrical.  For plumbing it is 50/50 in my area at least.  For everything else you can do it yourself.  If you do not have experience for some projects or do not have a reputation, please count on your inspector to treat you different.  Some are nice and helpful, other will nitpick your work until you get a pro.  But when pulling permits if it isn't electrical or major architectural I would assume you don't need a pro and even for those I mentioned you can ask city if you can do it yourself.  (example - often I have taken out a load bearing wall.  If I well over engineer the cross beam needed many inspectors tell me not to worry about architect sign-off.  It is a strategy I use often - pay $75 more for beam plus better beam better for future owners and save $300 on architect)