There several answers. First, all programming languages let you intersperse comments with the code. They are used to explain things that might not be obvious when just looking at the code. Second, there are often separate design documents that describe the overall organization of the program, major data structures, etc. for complex projects there can be a variety of documentation. E.g testing plans and the results of tests. Also, some comments aren’t just narration, but have a specific structure. E.g. there may be structured comments for every function, with a brief description of its parameters and what it does. There are tools that will pick those comments out of the code and turn them into a separate document.
for a big project there can be people whose only job is to track the documents.