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?
It's kind of automatic: if two functions $f,g:S\rightarrow S$ (where $S$ is any set) are such that $f\circ g$ is bijective, then $f$ is surjective and $g$ is injective. Hence $f^2$ being the identity implies $f$ is also bijective.