Below is an animation demonstrating this same result with an actual GPS signal. The top plot shows the received signal after being translated back to baseband (by multiplying with a phase aligned carrier at 1575.42 MHz) being slid past the code. When shift=0 the code is aligned with the received signal. The second linemiddle plot is showing the resulting sample by sample product of the received sequence with the code, and in blue along with the thirdaverage of these samples in green. The third plot shows the sum over the 1 msaverage alone showing that we can clearly distinguish when a code durationalignment occurs. Watch how the third plot increase significantly as shift moves through zero:
The blue line in the second plot as the sample by sample product still appears very noise like: if we took a histogram of the values, it would very much be a Gaussian bell curve with almost as many samples going positive as going negative. If there was no noise, after the time-aligned product all of the samples would be positive.So because Because of the underlying demodulated code, buried in that noise, there will be slightly more positive than negative values (the bell curve will be shifted ever so slightly to the right). When we sum all the samples (or equivalently average which only differs by a scaling constant) this reduces or filters out the noise and we will see the result as a higher average value (which is what the third plot is). Specifically the standard deviation as shown by the bell curve mentioned above will reduce by $\sqrt{N}$ where $N$ is the total number of samples (here 1 sample per chip or 1023).
I mentioned in the first paragraph that GPS sends the C/A code 20 times for each data bit. In the above plot we are correlating over 1 ms (one 1023 chip C/A code sequence interval) and thus see 20 peaks for each data bit, and we see the reversal associated with sending a zero instead of a 1. In this 50 ms capture, we are seeing a portion of the data sequence 1 - 1 - 0!