Does random sampling cause zero conditional mean?
The $E(u_i|X_i) = 0$ can hold even without having simple random sample or random assignment. However, random assignment guarantees this will hold (in expectations). A violation of $E(u_i|X_i) \neq 0$ is typically consequence of omitted variable bias. For example, in regression of education on wages reason why $E(u_i|X_i) \neq 0$ can be that experience also affects wages and if people with different education have different experience this will result in $E(u_i|X_i) \neq 0$.
Random assignment of $X$ solves this issue. For example, lets consider $X_i$ to be treatment status $X_i = \{0,1\}$ following Angrist and Pischke Mostly Harmless Econometrics. Now let $Y_{i}$ be potential outcome based on $X_i$ so that we have:
$$ Y_i \begin{cases}
Y_{1i} \text{ if } X_i=1 \\[2ex] 
Y_{0i} \text{ if } X_i=0
\end{cases} $$
As a consequence observed outcomes will be given by:
$$Y_{i} = \underbrace{Y_{0i}}_{\beta_0 } + \underbrace{(Y_{1i}-Y_{0i})}_{\beta_1}X_i\tag{1} $$
Now the above in expectation notation implies that:
$$\underbrace{E[Y_i | X_i = 1] - E[Y_i | X_i = 0]}_{\text{observed difference}} = \underbrace{E[Y_{1i} | X_{i} = 1] - E[Y_{0i} | X_i = 0]}_{\text{Average treatment Effect on Treated}} + \underbrace{E[Y_{0i} | X_{i} = 1] - E[Y_{0i} | X_i = 0]}_{\text{Selection Bias}} \tag{2}$$
Presence of selection bias would cause $E(u_i|X_i) \neq 0$.
However, note if we use random assignment of $X_i$ it eliminates the problem as it makes  $X_i$ independent of potential outcomes. If they are independent then $E[Y_{0i} | X_i = 1] = E[Y_{0i} | X_i = 1]$. Substituting this back to the 2 we get:
$$E[Y_i | X_i = 1] - E[Y_i | X_i = 1]= E[Y_{1i} | X_{i} = 1] - E[Y_{0i} | X_i = 1] \\ 
= E[Y_{1i}- Y_{0i}  | X_{i} = 1] \\ = E[Y_{1i}- Y_{0i}] .$$
This eliminates selection bias and ensures $E(u_i|X_i) = 0$ (although note random assignment is no silver bullet,  there could be various different issues that are still).