In either case, why did the probe attack Spock? What logical purpose did it serve? Vejur had no emotions, so it couldn’t have been angry and out for revenge against something it doesn’t even recognize as a life form.
I think it's a mistake to characterize the probe's action as an attack. V'Ger didn't see it as an act of violence, merely an act of data collection. The Ilia probe described it as "reduc[ing] to data patterns." When the probe first arrived, Kirk told everyone not to interfere. ("Absolutely I vill not interfere!") So as far as the probe was concerned, those organic bodies around it were just inert objects, not worthy of its attention as it studied the information contained in the machine entity called Enterprise
. But then one of those organic bodies demonstrated mobility and damaged its host, interrupting the probe's data download. That demonstrated that the organic bodies were worthy of further investigation, so the probe attempted to take a sample. And it wasn't too picky about which sample it took, since when Ilia got in the way, the probe took her instead of Spock. That makes it pretty clear that it wasn't specifically an act of retaliation against Spock.