Is the analogread function averaging the samples taken by the ADC?
As far as I understand the analogread() function samples an analog input at 10kHz rate.


No, it samples an analog input at once per invocation. This means that if it is run 10000 times within a second (assuming it can be run that many times within a second) then the code is sampling at 10kHz. But if it's run only twice per second then the code is sampling at 2Hz.