why does my ceiling fan change direction 2or3times before it finally stays in one direction?
It's probably an optical illusion. The "wagon wheel effect"

You are probably viewing it in light produced by a fluorescent lamp rather than an incandescent lamp.

There do exist electric motors that can work in either direction but no motor will speed up then stop and start working in the reverse direction all by itself.