It could be a bad (or failing) starter drive (a.k.a. Bendix drive).
The starter could be loose.
There could be a spot on the flex plate (a.k.a. flywheel) where the teeth are damaged and will not engage with the starter. There is usually, but not always, a grinding noise when this is the case. Trying several more times may help. Turning the engine to a different spot may help (large socket on the nut that holds the pulley on the front of the engine crankshaft).
There could be other broken parts in the starter.
If it were a problem with the engine, you would not hear the starter spinning. Same thing if it were the batteries.