Learning to understand regionally accented Mandarin

As soon as you leave the classroom, you will notice that people don’t speak Chinese the way your teacher and textbook do. Why is that, and what can you do to learn to understand regionally accented Mandarin?