If all the brain ever "sees" is action potentials, how do we know that one set of action potentials denotes a flash of light, another one signifies a loud sound, etc ?
The fundamental way in which this works is by geography: signals triggered by different stimuli travel by different pathways to different regions of the brain that are specialised for dealing with the sorts of information they contain.
For example, visual signals from the retina pass down the optic nerve and (after a few interesting twists and turns that, inter alia, send the left and right halves of each visual field to different brain hemispheres) wind up in the visual cortex, which contains neuronal networks adapted for recognising different structures and regularities in the image. Whereas sound information from the ears, after an even more tortuous sequence of processing steps, winds up in the auditory cortex.
Along the way, the signals will typically be split up across many neurons and reintegrated into new signals that pick out different kinds of information. So a particular stimulus will result in a complex spatio-temporal pattern of action potentials firing across many regions of the brain.
Conceptually, the further along this process you go, the more abstracted the signal probably becomes, so that it stands for a collection of events and ideas and thoughts rather than for excited photoreceptors or vibrating hair cells. But exactly how this parsing of the sensory content eventually turns into perception and conscious recognition is essentially unknown.
Just adding some metaphors in support to the excellent answer by walkytalky.
Our brain is like a huge processing center that can be seen from techni's prospective as a sort of a data center with parallel processing of hundreds of thousands of inputs with processing cores scattered throughout the complete brain.
Human brain (medulla) is connected with the rest of the body through special types of nerves that convey the information to brain (sensory, centropetal nerves) or deliver information from brain to the target organs (motor or centrofugal nerves) or both (mixed nerves).
I intentionally use the term "medulla", because this word comes from origin where it is applied to somwwhat more than brain: the spinal cord is also "medulla" (medulla spinalis), as well as the part that connects the spinal cord with the brain itself (medula oblongata).
The nerves that come directly from the brain are called cranial nerves. There are only 12 pairs of them in humans, numbered using Roman numbers (from I to XII) and every pair has a specific function: I bringing olfactory information (about smells), II -- the optic one, III -- moving the eyes etc.
The counterparts of these nerves in spinal cord are spinal nerves, which go through the holes between single vertebrae.
Brain and CNS in general can locate the information input and determine the information type judging by the input source using these nerves.
Besides the classical sensory information, like those from eyes coming via optical nerves into CNS, there is also some sensory information that is conveyed through autonomous nerve system, that is less specific and can not be localized as well as in case of sensory information coming via sensory input. Pain, for example, or the feeling of pressure belongs to the type of information coming via vegetative nerves.
The complete brain surface (so-called cortex) is mapped into special zones, called Brodmann zones, depending upon prevailing neuron types and (secondary) role in information processing.