Because “doc” is in the default namespace and “//p” matches elements in no namespace.
This would work:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xpath-default-namespace="http://www.w3.org/1999/xhtml" version="2.0"> ...
So would this:
<xsl:value-of xmlns:x="http://www.w3.org/1999/xhtml" select="count($doc//x:p)"/>