My shadows aren't lined up towards the end of the wall

My shadows aren’t working right. Wherever the shadows come to the end of a wall or come across a corner, they almost always do what’s shown in the image. How can I fix this?