Some dogs love to sleep in that position and are only totally relaxed lying on their back. Maybe you have a dog like that!!
But why do some dogs do this behaviour. It stems back to their ancestry where the Wolf showed his tummy when trying to diffuse a threat and appease another Wolf attacker. By showing his underside he would be communicating to the other Wolf that he was not a threat. We see this behaviour from our dogs today, and this piece of natural canine behaviour. It is often seen in puppies when they meet bigger dogs or people when they find themselves in situations that are overwhelming. Puppies often urinate too . Also our dogs are super smart and when our beloved canine friend lies with his belly towards us we often lean over and tickle them or give them really lovely belly rubs! So, this behaviour really works for dogs and brings a smile to our face too. It works too when a dog presents their tummy to avoid a threat from another dog as the other dog perceives that they are no threat and any aggression is often avoided .
It is NOT helpful however if your puppy or young adult dog meets and greets everyone like this . They can often be covered in dirt or wee ends up on your friends best carpet or even their foot! You can encourage a 'sit for a greeting' instead but you do have to been prepared and fast! Just before your dog rolls over, offering the tastiest, smelliest treat works best to stay upright. if they do rollover then the greeting stops and you just both walk on if on a free run or ignore. The main point to communicate to your dog is that rolling over showing his tummy results in nothing scrummy appearing.
If you have a young puppy urinating on greeting, keep all greeting very low key and end the greeting before it gets wet. Then work out how best to begin training a sit to greet instead, but keep it simple and easy for puppy to succeed. This is so he gets message that the alternative pays so much better!