Configuring ADC on Nucleo-F401RE in Arduino IDE gives erratic values for input freq greater than 100Hz
You are hitting limits when Arduino IDE starts being "unfriendly" and it is in my opinion easier to use more "professional" IDE. Your current code has problem that you make 1 ADC conversion (with X default parameters) and then you send them through serial link to PC. This is slow, especially if you are using a lot of HAL drivers and standard functions with a lot of overhead.

For your project, if you want to achieve reliable ADC sample frequency you will need to use set up ADC yourself and transfer data to SPI via DMA. You can setup all of this in Arduino IDE but I think it can be done much more easily in other IDEs. You can find list of recommended IDEs on STM page about your board.