Minecraft wiki entry for Development_versions, associated text: "It actually is a bug, it tries to rotate the body to the direction you are walking, but it can only do it so far, that is also why it basically picks a 'random direction'. Now it can actually understand when it is walking backwards and it stopped doing that weird behavior." – u/_Grum on Reddit, April 22, 2017