Setting desired sampling rate in Arduino Nano

I want to set 25KHz ADC sampling rate using timer prescaler, ADC prescaler and timer top.
Here I'm attaching my code to check the sampling rate and getting 61KHz instead of 25KHz.

Please check anything wrong.

int numSamples=0;
long t, t0, sampletime;
volatile int analogValue;

void setup()
{
Serial.begin(2000000);

// // TCCR1A to 0 (no pwm), and initialise TCR1B to 0
TCCR1A = 0;
TCCR1B = 0;
ADCSRA = 0;

// TCCR1B = (0 << CS12)|(0<<CS11) | (1<<CS10);
TCCR1B |= 1;

// Set CTC Mode with TOP value set to be ICR1
TCCR1B |= (1 << WGM12);
TCCR1B |= (1 << WGM13);

// Set TOP value of timer1 to give desired frequency
ICR1 = 639;

ADMUX |= (0 & 0x07); // set A0 analog input pin
ADMUX |= (1 << REFS0); // set reference voltage
ADMUX |= (1 << ADLAR); // left align ADC value to 8 bits from ADCH register

// sampling rate is [ADC clock] / [prescaler] / [conversion clock cycles]
// for Arduino pro mini ADC clock is 16 MHz and a conversion takes 13 clock cycles

ADCSRA |= 4;

// Set the trigger source for adc trigger to timer1 compare match B
ADCSRB |= (1 << ADTS2);
ADCSRB &= ~(1 << ADTS1);
ADCSRB |= (1 << ADTS0);

}

ISR(ADC_vect)
{
byte x = ADCH; // read 8 bit value from ADC
numSamples++;
}

EMPTY_INTERRUPT (TIMER1_COMPB_vect);

void loop()
{
// Enable the ADC
ADCSRA |= (1 << ADEN);
// Set conversion bit to zero
ADCSRA |= (1 << ADSC);
// Set auto trigger of adc (adc will trigger on the selected signal, in this
// case timer1 reaching a certain value)
ADCSRA |= (1 << ADATE);
// Enable adc interrupts (this allows an interrupt to be called once the adc has
// finished a conversion
ADCSRA |= (1 << ADIE);

// Allow timer interrupts for timer1 B
TIMSK1 |= (1<<OCIE1B);
// Set timer value to 0
TCNT1 = 0;

if (numSamples>=1000)
{

t = micros()-t0;  // calculate elapsed time

Serial.print("Sampling frequency: ");
Serial.print((float)1000000/t);
Serial.println(" KHz");
delay(20);

// restart
t0 = micros();
numSamples=0;

}

}

Do you need an exact 25 kHz sampling rate?

// Analog sampler.  Trigger analog samples at a time interval selected by Timer1

const uint32_t INTERVAL_MICROSECONDS = 40; // 25 kHz
const uint32_t CLOCKS_PER_MICROSECOND = F_CPU / 1000000ul;
const uint16_t TIMER1_TOP = (INTERVAL_MICROSECONDS * CLOCKS_PER_MICROSECOND) - 1;

const byte MAX_SAMPLE_COUNT = 3;
volatile byte SampleCounter = 0;
volatile uint16_t SampleBuffer[MAX_SAMPLE_COUNT];

void setup()
{
  Serial.begin(115200);
  delay(200);
  Serial.println("AnalogSampler started");

  // Set up the ADC to start a conversion when Timer1 overflows
  ADMUX = 0;
  ADCSRA = 0;
  ADCSRB = 0;
  DIDR0 = 0;

  // Select the AVCC reference and input pin A0
  ADMUX |= _BV(REFS0);

  // Set ADC clock prescale.
  // For full resolution (10 bits) the ADC clock must be 
  // lower than 200 kHz.  At the expense of a few 
  // LSBs we can crank the ADC clock up to 1 MHz
  // and get 74000 samples per second.

#if (F_CPU > 8000000ul)
  // On a 16 MHz Arduino use a prescale of 16
  // The next higher available prescale is 128.
  ADCSRA |= _BV(ADPS2) | _BV(ADPS0); // Prescale = 16 = 1 MHz
#else
  // On an 8 MHz Arduino use a prescale of 8.
  // The next higher available prescale is 64.
  ADCSRA |= _BV(ADPS=1) | _BV(ADPS0); // Prescale = 8 = 1 MHz
#endif

  // Select auto-trigger source: Begin Conversion on Timer1 Overflow
  ADCSRB |= _BV(ADTS2) | _BV(ADTS1);

  // ADC Enable, Auto-trigger enable, Clear interrupt flag, Enable interrupt
  ADCSRA |= _BV(ADEN) | _BV(ADATE) | _BV(ADIF) | _BV(ADIE);

  // Start Timer1 overflowing every INTERVAL_MICROSECONDS
  TCCR1A = 0;
  TCCR1B = 0;
  TIMSK1 = 0; // Disable all Timer1 interrupts

  ICR1 = TIMER1_TOP; // Set INTERVAL_MICROSECONDS

  // Set WGM 14 (0b1110): Fast PWM, TOP in ICR1, TOV1 at TOP
  TCCR1A |= _BV(WGM11);
  TCCR1B |= _BV(WGM13) | _BV(WGM12);

  TIFR1 |= _BV(TOV1);  // Clear any pending Timer1 Overflow

  // Start Timer1 with Prescale=1
  TCCR1B |= _BV(CS10);
}

// ADC Conversion Complete interrupt service routine
ISR(ADC_vect)
{
  TIFR1 |= _BV(TOV1);  // Clear the pending Timer1 Overflow Interrupt

  uint16_t val = ADC;

  if (SampleCounter < MAX_SAMPLE_COUNT)
  {
    SampleBuffer[SampleCounter++] = val;
  }
}

void loop()
{
  if (SampleCounter == MAX_SAMPLE_COUNT)
  {
    // All samples have been collected.  The ISR won't be doing anything
    // until the SampleCount is reset.

    Serial.print(micros());
    Serial.print(", ");
    Serial.print(SampleBuffer[0]);
    Serial.print(", ");
    Serial.print(SampleBuffer[1]);
    Serial.print(", ");
    Serial.println(SampleBuffer[2]);
    Serial.flush(); // Make sure all the character get sent

    SampleCounter = 0;
  }
}

Thank you.
What is the maximum achievable sampling rate?

The maximum supported ADC clock frequency is 1 MHz so 1,000,000/13.5 is 74074.074... Samples Per Second in free-running mode.

If you don't care about "supported" you could use higher clock rates (2, 4, or 8 MHz) and see what happens.

https://www.gammon.com.au/adc shows some testing results.

If you go one step faster than the 13us/76kHz /16 ADC clock prescaler to the /8 6.5us/153kHz speed, you lose a bit or two of accuracy. If you try faster than that, it degrades quickly.