This is an already answered question in this website:
Show that a finite group with certain automorphism is abelian
I have solved the question by myself and got the result but one thing I noticed is that there was not need of the given function $f$ to be onto. We only used fixed point free monomorphism , $f^2=I$ property and that $G$ is finite. Then why is it given to be automorphism? Am I getting something wrong?