You haven't understood two of the most basic concepts of XSLT: context, and template rules. This is what your code is doing:
<xsl:if test="ns0:Messages/..../details/name = A">
<ns0:Message1>
<ns1:bpm_in01_mt xmlns:ns1="http://afes.temp.com/test01">
<xsl:for-each select="ns0:Messages/ns0:Message1/ns1:bpm_out_mt/details">
The xsl:if says "if there is an element selected by the path ns0:Messages/..../details/name whose value is equal to A then..." Your context node is the document root, so you are testing whether there is such an element anywhere in the document. If there is, then you do the xsl:for-each, which again selects from the document root, and thus processes all the selected elements in the whole document, whether or not they matched the condition in the xsl:if.
(There's another little mistake in your code as well, you should have said ='A' rather than =A. A without quotes means child::A, that is, an element whose name is A.)
What you want to achieve is to transform a details element with name=A intoa Message1, and to transform a details element with name=B into a message2. So write two template rules:
<xsl:template match="details[name='A']">
<ns0:Message1>
<ns1:bpm_in01_mt xmlns:ns1="http://afes.temp.com/test01">
<info>
<xsl:value-of select="name" />
<xsl:value-of select="id" />
</info>
</ns1:bpm_in01_mt>
</ns0:Message1>
</xsl:template>
and similarly for match="details[name='B']"
Then just make sure the details elements are processed:
<xsl:template match="/">
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<xsl:apply-templates select="//detail"/>
</ns0:Messages>
</xsl:template>
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference