Actually in most areas you can do your own electrical, plumbing, etc, on your own home as long as it is not for sale, rent or lease.
You still may need a permit, not needed around here- OR/Wa for switch, recept, light fixture replacement, but much more than that, circuit extensions, New receptacles or new switches ( meaning new location) or new light fixtures/circuits need permits. That's on your own home. If it's a rental, apartments or something else that's a different story and different rules apply.
I don't agree with all of it but I've seen some pretty knarly work done by owners and handymen that is quite surprising that hadn't caused a fire, and some that had burned but the box fortunately contained it. What's bad is to find a poor splice that is not boxed and covered with old newspaper and such in an attic, with obvious signs of heat.
A fire just waiting to happen.