Sandboxed Mac apps have access to their own container which includes directories like Documents/ and a temporary directory and more where they can save anything just like on iOS.
Though, there is also a third type of Documents directory, the kind located at paths such as ~/Library/Mobile Documents/com~apple~TextEdit/Documents. This is part of iCloud Drive and is the same directory that you get in Finder by going to iCloud Drive -> TextEdit. Very confusing.