Your main template, <xsl:template match="/">
, runs only once - namely for the <countData>
element.
Which means that you either forgot to recurse:
<xsl:template match="*" mode="TimeFrame">
<xsl:if test="count[@countId=37] or count[@countId=39]">
<magic>Only hitting this once for countId 37</magic>
</xsl:if>
<xsl:apply-templates mode="TimeFrame"/> <!-- ! -->
</xsl:template>
...or you failed to set the right context for the the main template:
<xsl:template match="/countData"><!-- ! -->
<xsl:apply-templates mode="TimeFrame"/>
</xsl:template>
<!-- or, alternatively -->
<xsl:template match="/">
<xsl:apply-templates select="countData/*" mode="TimeFrame"/>
</xsl:template>