In addition to studies of patient with particular focal lesions, brain function in particular areas can also be studies in other ways. For one, functions are often conserved between species so that studying animals can give some indication of the role of a brain region in humans. This may be done by applying lesions or through treatment with genetic or pharmacological agents.
Brain function can also be studied in healthy humans through invasive or non-invasive methods. Sometimes electrodes are implanted in preparation for neurosurgery and these recordings can be used to learn something about brain activity associated with different tasks that the patient is asked to perform.
Non-invasive methods allow for the imaging or manipulation of brain function. Methods like functional magnetic resonance imaging or magneto-encephalography make it possible to record aspects of brain activity. In the analysis, statistical procedures are applied that identify the areas that are most closely associated with a particular tasks, which leads to the association of brain area and function.
In contrast, trans-cranial magnetic stimulation can be used to manipulate brain function for a short time. When this disruption leads to an impairment on s particular task, the brain area that was targeted is thought to be involved in that task.
However, the current view is moving away from describing simple association between an area and a behavioural or cognitive function. The old approach has sometimes dismissively been termed "modern phrenology". In more recent years, the focus has shifted towards describing the role of a brain structure within a wider network.
You will find many more details about this in any introductory cognitive neuroscience textbook, if you are interested.