The matched filter is not maximizing the difference between $a_1$ and $a_2$ but maximizing that difference divided by the noise component $2\sigma_o$. So either the difference stays the same and the noise is minimized, or the noise stays the same and the difference is maximized. Which occurs all comes down to scaling that is actually used. The main point is the matched filter (under condition of white noise specifically and only!) will maximize the signal to noise ratio!
A simple way to see this intuitively is the case of a matched filter for $N$ samples of a constant value in the presence of white noise. If the noise is indeed white (meaning constant power spectral density in frequency), then it will necessarily be independent from sample to sample (any dependence or memory indicates filtering!). Since the signal is constant, the matched filter can be multiply each sample by $1$ and then sum the results, which just means sum all the samples (similar to an "Integrate and Dump" matched filter). If we add all the samples, the constant value will grow by $N$. If we add all the noise samples, the standard deviation of the noise $\sigma_n$ will grow by $\sqrt{N}$! To refer back to the "scaling" issue mentioned above, we can use these values directly to determine the signal to noise ratio (as a power quantity it would be the square of both), or we can scale our signal back to it's mean value by dividing both by $N$ (such that the mean has stayed the same and the noise has decreased by $\sqrt{N}/N = 1/\sqrt{N}$.).
Thus we have improved the magnitude of our signal to the magnitude (standard deviation) of the noise $\sqrt{N}$. To see this experimentally we would need to repeat the experiment many times independenty in order to get a statistically viable estimate of $\sigma_n$. I recommend any student that really wants to understand this (including developing an intuition for it beyond the math) to confirm this experimentally, given how simple it is to do with the common tools available to us (for example, Matlab, Octave or Python).