I've had this problem since day one (I purchased Sims 4 about a month ago). I do have CC content, but that is a recent addition and did not exist when the problem began happening. I have repaired the game to no avail, I re-lock the doors to no avail, and I replace the doors to no avail.
I have three games it happens on (the fourth game I have not used the lock door feature yet so it's untested).
In the first game, I have 8 sims in the household and wish for the toddlers to stay on the ground floor where their beds and potties are as opposed to wandering around the entire lot (the biggest lot in the game and I have used all four above ground floors and both underground floors... this causes issues if they're tired or hungry etc). I also wish for sims to not enter the section I have called "The Lair", an underground apartment section built for only one sim who has now moved out. I also have a show Speakeasy under the house which is locked for everyone yet they still manage to enter (and ironically leave one of the mischief books behind). The front door does not work and allows vampires to attack. Sims frequently enter rooms and get stuck in there and I have to hunt to find them (non-household members I mean)
The only door that has been consistently locked in this game has been the living room door for the cat. I locked it because she's afraid of the TV, and she has never been able to enter.
In the second game, It is an apartment-like building (university halls) but the sims frequent other's private quarters and get into the staff areas.
The third game is a Victorian game and I do not want one of the sims to gain the Mixology skill... yet she managed to do so. I locked the globe behind 2 doors, both she has managed to enter. Often she gets the globe icon bubble thing to do the action, but it vanishes like she can't complete the action (which is what I want) but sometimes she somehow manages to enter as if the doors are unlocked and she is able to exit and re-enter freely. The front door seems to be working fine for now, and the locks for the toddler worked throughout the entire toddler stage (though admittedly the lot is not nearly as big and so it was just the one door I needed to lock)
This is a problem that occurs on-and-off, about 99% in the first and second games (I literally have no control in those with human sims), and the third about 50% of the time.