Why is swearing such an in built part of the mind? My wife suffered from a Traumatic Head Injury several months ago. She had 2 Brain surgeries due to bleeding of the brain. As a result, she is unable to speak words other than yes, no, don't know and there. She has to learn through Speech and Language Therapy how to say each word. However, right from the start, she's been able to easily say sentences such as "For fucks sake Scott" and "Fuck off". Is there something about swearing that is built in?
The mind is a large landscape as you are finding. Speech centers where new or current ideas are formed into words rely on other areas where conversion elements have already been worked out some time ago. Ready made phrases for non-new ideas and reliable conversation can be brought up with little or no effort. With these peppered into speech one can sound as if they are otherwise fully conscious and thinking about what they are saying. 

You can see this when speaking with people when they cannot stop adding the same phrase to their sentences. Such as "...if you know what I mean." Though a complex phrase it has its own quick 'subroutine' to send it to the mouth. After hearing this over and over you would guess that the speaker is not as self aware as you first suspected. This can reflect the effort made as they cast about for ideas and how to express them.

The foul language which would be rare in earlier days probably reflects her frustration and anger with her difficulties in forming speech. Normally there are filters to prevent using bad language if only to spare feelings of listeners. These can also be compromised when the effort is to get any speech together. You can think of her speech as letting you in on parts of her internal, normally private, dialogue as she struggles to express herself. 

With patience this should improve as she re-maps her speech abilities along with the boundaries of what to say and not say. 

I suggest you read The Man Who Mistook His Wife for a Hat by Oliver Sacks to see how disparate the areas of the mind can be. Good luck to you both.