First, compared to Mercurial's branches, Git branches are "anonymous".
This means, a commit which was recorded "on a" branch (most of them are,
but this is not required) bears no information about the branch it was
committed to.
This is intentional.
In this model, a branch is merely "a pointer" to some commit which—through
the parent/child(ren) relations—can be used to traverse the history of changes backwards.
The consequence is that any commit recorded in a repository may be
reachable via any number of branches (and tags).
So, in this model, any commit may "be on" any number of branches at the same time.
Second, a merge commit not only records the name of the branch being
merged (this is merely the default behaviour; it's perfectly legal to
merge a chain of history by naming its tip commit or override/edit
the merge message) but actually the tip commit of that branch at the time
of the merge. So this information is recorded in the merge commit itself,
and that line of history is permanently there: say, if you have merged
branch B into branch A resulting in a merge commit M, you can refer to
the tip of that branch B at the time of the merge via M^2
which means
"the second parent of M
" (the first parent is the tip of A at the time
of the merge).
Given that Git branches are lightweight, should you need to
"get back in time" to "work on" B at the time of the merge,
you can just do
$ git checkout -b oldB M^2
which is "create a new branch named «oldB» pointing at the 2nd parent
of the merge commit «M» and check it out".
After you're done with exploring the old state of B, just get rid of that
"oldB" branch.
To round up, Git is best approached from another angle: think in term
of the graph of interconnected commits with branches merely pointing
to certain "entry points" to that graph.