Dogs lie on their backs primarily to show subservience to a dominant "pack leader" (another dog or a human), and/or to show that they are looking to play.
A common theory is that they are showing submission; when they think that they have done something to upset their owners, they lie on their back to show respect.