# Why is the explanatory variable non-stochastic or fixed in repeated samples?

I am studying econometrics. I have been learning about deriving the variance for the OLS slope statistic in a simple linear regression model.

Why is the explanatory variable considered to be non-stochastic or fixed in repeated samples?

This idea makes no intuitive sense to me because I thought that in econometrics we only deal with observational data, and hence we cannot control what the values for the explanatory variable will be.

The main reason is simply for teaching purposes: Assuming fixed explanatory variables ensures that the error term is independent of the (deterministic) variables, $$E(u|X) = 0$$ holds by definition, see also here. Sometimes you started with fixed / deterministic explanatory variables in a first undergraduate course to explain the basic ideas and algebra. Then proceed with stochastic variables to make clear that in the real world correlation and causality are not always the same.
I assume this is a regression model. The main reason is inferential, the explanatory variable(s) are treated as fixed for purposes of inference. The regression model $$Y= X\beta + \epsilon$$ is a model for the conditional expectation of $$Y$$ given $$X$$: $$\DeclareMathOperator{\E}{\mathbb{E}} \E\left\{ Y | X=x\right\} = x^T \beta$$ which is assumed to hold whichever value of $$x$$, so variation in $$x$$ has no role in describing that relation.