How source code is best organised is related to the mental conceptualisation of the developers who produce that code.
The basics of software are data structures and algorithms - at least as the late Niklaus Wirth had it.
A module will correspond to whatever set of structures and algorithms are designed as, and conveniently thought of as, a single unit.
A small, simple application doesn't have to have any modules, but in larger applications there invariably have to be internal divisions which are not necessarily apparent to users of the application through its shell. There may in fact be more than one level of modularisation.
A basic principle of where to draw the boundary lines of modules, is the ability to explain the design and workings of the module almost purely (that is, to a very great extent) in its own terms. To explain one module, the design artefacts it contains, and why the design takes a particular form and not another, you shouldn't already have to explain the fine details of everything else in the application.
Another principle is that the explanation of the internal workings of a module should be much more complicated than explaining its exterior interface.
By having modules with complicated interiors but simplified exteriors, you can then reason about how two or more such exteriors interface, whilst hopefully not having to think as much about the internal details at the same time.
Even though exteriors of modules themselves may seem fairly simple when considered individually, reasoning about the behaviour of assemblages of them is a source of significant additional complexity and mental workload.
The complexity of the whole when modules are composed often seems to be a multiple or exponentiation of all their individual complexities, so that keeping the exteriors of modules as simple as possible whilst containing as much complexity as possible within them, so as to moderate as much as possible the exponential complexity that has to be analysed when they are composed, is how an application of considerable total complexity can be built and still remain manageable by developers with finite intellect and mental capacities.
Another aspect of modules may be to aid the developer in navigating around the source code and understanding how data flows around the application, or how different parts of an application come into use at different stages of a business process (and that business process itself may be staged and conceptually modularised in order to assist in its comprehension by the staff who manage and operate it, so then the software which helps mechanise the process takes on the same modularisation).
What is nevertheless very difficult to do, is to explain how an application should be modularised, without being familiar with exactly what it is supposed to do, and having a subjective sense of how much complexity it involves.
When I design any kind of software, there are often multiple iterations of design, in which I discover that complexity in a particular place is running out of my control or that it is becoming subjectively awkward to understand, and I then devise targeted ways to reduce that complexity or find a way to re-conceptualise in a way that I find imposes fewer mental demands on me all at once.