After formatting, the camera's firmware will know *exactly* how much space is available on that chip, how all the clusters are organized, and the starting memory address for each cluster.
The concept is very similar to formatting a 3.5" Floppy Disk (remember those?). The camera's FORMAT operation does all this silently, in a few seconds, to prepare the raw chip for holding your picture files. Along the way, an index table is created to record the id & address location of all the clusters that are now available to hold data. Very generically speaking, the format operation takes all that raw space, and quantifies it by slicing it and dicing it into fixed-size chunks (sometimes called 'clusters' in computer terms). The SD card is basically a static memory chip (various capacities).