An independent variable is endogenous if it is correlated with the error term (source).
In the regression framework, this may happen (only?) in case of omitted variables, simultaneity, or measurement error in the dependent or independent variable. A proof that these cases lead the independent variable to be correlated with the error term is provided in [1].
But in the literature, sometimes you find that the fact that an independent variable is chosen by the subject under study makes it endogenous.
For example, in [2], we can read:
For example, a researcher might be interested in testing whether management earnings forecasts affect the cost of capital. In this case, the endogenous indicator variable (D) indicates whether the company issues an earnings forecast and the dependent variable is the cost of capital. [...] D is endogenous.
So the fact that management chose the earnings forecast makes the variable endogenous.
I would like a mathematical proof that the fact that a variable is chosen by the subject under study makes it correlated with the error term, or, equivalently, makes it a case of the previously discussed 3 cases of endogeneity.
[1]: Roberts, M.R., Whited, T.M., 2013. Endogeneity in Empirical Corporate Finance, in: Handbook of the Economics of Finance. Elsevier B.V., pp. 493–572. https://doi.org/10.1016/B978-0-44-453594-8.00007-0
[2]: Lennox, C.S., Francis, J.R., Wang, Z., 2012. Selection Models in Accounting Research. The Accounting Review 87, 589–616.