Why Some Grammar Distinguish Declarations with Statements?

Even though variable declaration can be considered statement in the AST, they are not valid in all places where statement can fit. For example, we don’t want to use variable declaration as a branch in if statement:

if (cond) int x = 5;