why is the shadow of an object formed opposite to the direction of light source
This is because the light always goes away from the light source. When it falls on things, the hings reflect it back. In doing so, light is not able to reach certain areas behind those things, and a shadow is formed there.
Thus, a shadow is formed opposite to the direction of the source.