Q:

Number of $\mathbb F_p$ points constant mod $p$?

I have some affine varieties $X$ defined over $\mathbb Z$, and associated integers $c(X)$, with the property that $\# X_{\mathbb Z/p} \equiv c(X) \bmod p$ for all $p$. (In particular $c(X)$ is usually $1$ in my examples, but not always.) 

Is this property related to any other interesting properties of $X$, e.g. "ordinary", "unirational", etc.?

I am happy to entertain conjectures, necessary conditions, sufficient conditions, anything. I looked at the 33 occurrences of the word "constant" in Serre's Lectures on $N_X(p)$, but haven't delved deeper into that book.

A:

The Grothendieck-Lefschetz trace formula tells you that
$$ \#X(\mathbf F_q) = \sum (-1)^i \mathrm{Tr}(\mathrm{Frob}_q \mid H^i_c(X)),$$
where all cohomology is with coefficients in $\mathbf Q_\ell$.
Suppose all the cohomology of $X$ is of Tate type. For example, maybe there is a compactification $X \subset \overline X$ with a stratification such that the closure of each stratum has cohomology spanned by algebraic cycles. In this case,
$$ \mathrm{Tr}(\mathrm{Frob}_q \mid H^i_c(X)) \equiv \dim W_0 H^i_c(X) \pmod q,$$
 where $W$ denotes the weight filtration. Indeed, $\mathrm{Frob}_q$ acts as the identity on $W_0$ and as multiplication by $q^d$ on $\mathrm{Gr}^W_{2d}$. So in this case, your equation is satisfied, with $c(X) = \sum (-1)^i \dim W_0 H^i_c(X)$; equivalently, $c(X)$ is the Hodge-Deligne polynomial $E(X,u,v)$ specialized at $u=v=0$.
I know that Carel Faber (unpublished) used this to prove the existence of cohomology that is neither of Tate type, nor associated to Siegel modular forms of genus $\leq 3$, in the moduli space $\mathcal M_{3,n}$ for some $n$ that I can not recall. He computed the number of points mod $p$ for various $p$ and found that this was not a constant independent of $p$, nor was it a linear combination of traces on Galois representations attached to Siegel cusp forms (for the full modular group) of low enough weight and genus.

A:

Do you know that $\#X(\mathbb F_q)$ is a multiple of $p$?
If you do, then for all sufficiently large primes $p$, we have
$$\zeta(X) \equiv (1-t)^{-c(X)} \mod p$$
Hence each eigenvalue of Frobenius that appears with nonzero signed multiplicity is either $1$ or is a multiple of $p$.
In terms of Galois representations, you get that each Galois representation appearing in the cohomology of $X$ with nonzero signed multiplicity is either the trivial Galois representation or has its eigenvalues multiples of $p$ for almost all primes. (Well there's small issues if eigenvalues cancel each other but let's ignore those).
This is actually related not to ordinariness but to supersingularity. For instance, a supersingular elliptic curve always has $p+1$ points. However, we believe all Galois representations are ordinary most of the time. Moreover, even if this is false, it should be very unlikely that you can find a counterexample by some fixed explicit method, so I think we can assume it is true in your case.
So I guess all Galois representations of weight $i$ that appear with nonzero signed multiplicity should have Hodge numbers in the interval $[1, i-1]$.
This is a very weak geometric condition because it only concerns cohomology, as others have pointed out. But my understanding is that varieties like fake projective planes with simple cohomology but complicated geometry are hard to construct by explicit equations.
As others suggest, rational connectedness might provide a good geometric explanation for this. If the variety is also Fano, proving that might be easier than explicitly finding rational curves - one example of varieties where there is an elementary proof of this type of congruence is varieties given by low-degree equations, which are also always Fano.
Also, note that these statements should apply not just rationally but also to the boundary divisor and to any singularities, if they occur. More precisely, it would be interesting to see if you can explicitly write your variety as a class in the Grothendieck group of smooth projective varieties. In that case possibly all varieties that occur should have that nice condition.
One interesting thing - the simplest kind of affine variety, a smooth projective variety minus a smooth divisor, can only satisfy this kind of congruence with $c(X)=0$. (I see Jason Starr has already pointed this out.) In fact it's easy to see from the $\zeta$ function that if you write your variety as a sum and difference of smooth projective connected varieties, the total number of smooth projective connected varieties must be exactly $1$. That's sort of interesting, and maybe you can see that from another angle.

A:

Nobody seems to have mentioned Fulton's (?) trace formula. It says that the number of points mod p equals the alternating trace of Frobenius on coherent cohomology $H^i(X, \mathcal{O})$.  So - and this is probably exactly the same as Sawin's point- the easiest reason that the number of points is congruent to $1$ modulo $p$ is that all the higher cohomology of the structure sheaf vanishes. 

