When the light source is behind the object, the shadow will be in front of the object. This is because the object is blocking the light from reaching the area in front of it.
When the light source is in front of the object, the shadow will be behind the object. This is because the object is blocking the light from reaching the area behind it.
When the light source is to the side of the object, the shadow will be cast to the opposite side of the object.
The movement of the shadow is due to the movement of the light source and the object. If the light source or the object is moving, the shadow will move as well.
In some cases, the shadow may appear to be in front or behind you even when it is not actually in that position. This is due to an optical illusion.