In your expression, you are getting the 'last' ancestor with the class name of 'Users' for the text node you are on
...(ancestor::*[contains(@audience,'FLAG_')])[last()])...
But you really want to get the first one here. That is to say, the most immediate ancestor. The list of ancestors will start with the parent node, then the grand-parent, etc...
...(ancestor::*[contains(@audience,'FLAG_')])[1])...
Additionally, you say you don't want to compare the strings, just find out if the text node is first or last, but your current comparison is checking strings. So, if you have two text nodes with the same text (one of which is the first), then you will be get a rogue '[USER]' tag. To test if two nodes are the same node (as opposed to just having the same content), you can use the generate-id function.
generate-id() = generate-id(((ancestor::*[contains(@audience,'Users')][1])/descendant::text())[1])
Try this XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
<xsl:output method="text" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="text()">
<xsl:if test="generate-id() = generate-id(((ancestor::*[contains(@audience,'Users')][1])/descendant::text())[1])">
<xsl:text>[USERS]</xsl:text>
</xsl:if>
<xsl:value-of select="."/>
<xsl:if test="generate-id() = generate-id(((ancestor::*[contains(@audience,'Users')][1])/descendant::text())[last()])">
<xsl:text>[/USERS]</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
BUT.... Maybe you can take another approach. Looking purely at your XML and expected output, another approach that could be take is to have a template that matched any element with a 'users' class, and simply write out the start and end [USER] tag in that, with an xsl:apply-templates in between to select all text.
Try this XSLT as an alternative:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" >
<xsl:output method="text" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="*[contains(@audience,'Users')]">
<xsl:text>[USERS]</xsl:text>
<xsl:apply-templates />
<xsl:text>[/USERS]</xsl:text>
</xsl:template>
</xsl:stylesheet>