This can occur because the vehicle reports its current heading as the last known direction of travel, not the current direction the front of the car is facing.
So if you are travelling in reverse, or backed into a parking spot, you can expect the heading to show opposite the direction the front of the car is facing since the direction of travel is backwards.