The vessels which do the charting are equipped with high-definition active sonar (they ping), and these units are generally surface vessels which proceed at very slow speed, accurately plotting their position in three dimensions as they probe the depths.
Then there's the reality of priority - which parts of the planet will be charted first, and by which system? High-definition sonar is the method for key areas. But, there's limited funds and resources for this activity. The further away from shore, or from areas of interest (eg away from shipping lanes, drilling areas etc) we look, then in general you'll see the charts are also less accurate or complete. Some are very, very old. Then there's the political reality - how easy is it to enter an area and re-survey it?
Also, some of these areas are geologically active and can actually change over time - new islands, sea mounts and so on can greatly change the situation faced by ships and submarines.
As we know, a submarine will generally proceed without active sonar, listening as it slowly moves around. It has very good ears - but ears can't see. It hasn't a radar underwater, and GPS signals penetrate only so far below water (try putting your favourite device into a sealed bag and see how far underwater you go before you lose signal - not very!).
As an analogy, try walking around your house or yard at night, lights off, eyes closed. You know it well, you live there! You shouldn't bump into anything. So, let's test that theory. Your memory will help you get around, but the more you move the more likely you are to miscalculate your position, or generate inaccuracies in your mental map - and I'm confident that without an occasional check by turning on lights, or putting your hands out to check, you'll eventually bump into something. Also, if someone leaves Lego on the floor, or changes the navigational situation by closing a door without telling you - well, we've all seen Home Alone!
So, while it's an embarrassing thing for an expensive submarine to bump into something, it's not impossible. And, the USN has a number of recent surface-ship navigational shortcomings (the spate of destroyer collisions) - which proves these collisions can occur even when people aboard one ship can see the other ships or objects around them. So, system error, human error or just plain bad luck can all contribute to a collision - particularly for a submarine.