For semisimple groups (and the Poincaré group is not such), the number of
Casimirs (i.e., the number basic generators center of the universal
enveloping algebra) is equal to the dimension its Cartan subalgebra (maximal commuting subalgebra) which is the rank of the algebra. This is called
Chevalley's theorem.
The Poincaré group however is not semisimple (it is a reductive Lie
group given by a semidirect product of a semisimple (Lorentz) and an
Abelian group (translations)), thus this theorem is not valid in this
case (even if both ranks are equal to 2 in the case of the Poincaré
group, there is no general theorem for that).
For such groups the center of the universal enveloping algebra can be
characterized by the Harish-Chandra isomorphism , which is less constructive than the Chevalley's theorem.
There is a way to "understand" why the number of Casimirs of the
Poincaré group is 2. The Poincaré group is a
Wigner-İnönü contraction of the de-Sitter group $SO(4,1)$ which is semisimple and of rank 2.
The Casimirs of the Poincaré group can be obtained from the Casimirs of
$SO(4,1)$ explicitly in the contraction process. This is not a full proof
because group contractions are singular limits, but at least it is a way
to understand the case of the Poincaré group.