I'm restricting this answer to Illumina. Even then, I don't know about the exact details of the raw data analysis (it is a proprietary software).
Basically Illumina records the sequence based on photographic images. Each nucleotide has a distinct fluorescent label. In a cycle, a nucleotide is pumped and unincorporated nucleotides are washed off (this is repeated for all nucleotides). A laser excites the fluorophore and the emitted light is recorded in the form of a photograph. The template DNA is present in the form of clusters of strands (at a given location), which enables easy visual identification of the fluorescence.
Base calling is done using image analysis. Each image is analysed for intensities of different colours and based on this the quality score is calculated. The quality score is basically the log likelihood of a occurrence nucleotide at a given position (based on its colour intensity) compared to other nucleotides.
This is the most simple explanation of how Illumina does base calling. There are different kinds of errors and biases and there are different statistical approaches to correct for them.
Have a look at following references for more details: