When a person dies gas from the body is released inside the body.
When the gas inside the dead body is released upon death it causes the body to swell since the gas has nowhere else to escape.
The swelling of a dead body is the second stage of body decomposition and is known as microbial proliferation within a body is referred to as putrefaction.
That causes the swelling or bloating after death of someone.