Let $n \in \mathbb{N}$, suppose $n$ requires $d$ digits in it's base 2 representation, we'd like to show that $d = \lfloor \log_2(n) \rfloor+1$.
At most we have $n = 1 \ldots 1$, that is $d$ 1's in a row. But we know that is $$\sum_{i=0}^{d-1} 2^i = 2^d - 1$$
At a minimum the first digit is a 1 and the rest are zeros (since the powers start at 0 right to left, this is $2^{d - 1}$).
We now have the following bound on $n$. $$2^{d-1 } \le n \le 2^d - 1$$
Taking log base 2 on on the above inequality yields: (Call this inequality $\beta$)
$$d - 1 \le \log_2 (n) \le \log_2(2^d -1 )$$
Note: Taking the log respects the inequalities because $\log_2(\cdot)$ is a strictly increasing function (check it's derivative)
We will attempt to take the floor of $\beta$. Since $d-1$ is an integer $\lfloor d-1 \rfloor = d-1$, as for $\log_2(2^d-1)$, we must look a little closer.
Since $2^{d-1} \le 2^d - 1 < 2^d$ and , we know that $$d-1 = \log_2(2^{d-1}) \le \log_2(2^d - 1) < log_2(2^d) = d $$
Therefore $\lfloor \log_2(2^d - 1) \rfloor = d-1$ and so the result of taking the floor of $\beta$ yields
$$d - 1 \le \lfloor \log_2 (n) \rfloor \le \lfloor \log_2(2^d -1 ) \rfloor = d-1$$
In other words
$$d - 1 \le \lfloor \log_2 (n) \rfloor \le d-1$$
So
$$d - 1 = \lfloor \log_2 (n) \rfloor \Leftrightarrow d = \lfloor \log_2 (n) \rfloor + 1$$
I have written a proof for your equation ($4$) in the linked question, with the procedure to prove your ($1$) in this question being similar. First, to reduce the algebra involved, define
$$m = \lfloor \log_2 n \rfloor, \; \; j = \nu_2(n) \tag{1}\label{eq1A}$$
Since $m$ is the index of the largest non-zero binary coefficient of $n$, this means
$$n = \sum_{i = 0}^{m}c_i 2^i, \; 0 \le c_i \le 1 \; \forall \; 0 \le i \le m \tag{2}\label{eq2A}$$
Next, using \eqref{eq1A} and a change of the index variable, your ($3$) can be written as
$$\begin{equation}\begin{aligned}
n & = 1 + \sum_{k=1}^{\lfloor \log_2{n} \rfloor + 1} \left( \left\lfloor\frac{2n - 1 + 2^k}{2^{k+1}}\right\rfloor - \left\lfloor\frac{2n - 1 + 2^{k+1}}{2^{k+2}}\right\rfloor \right)k \\
& = 1 + \sum_{k=0}^{m} \left(\left\lfloor\frac{2n - 1 + 2^{k+1}}{2^{k+2}}\right\rfloor - \left\lfloor\frac{2n - 1 + 2^{k+2}}{2^{k+3}}\right\rfloor \right)(k + 1)
\end{aligned}\end{equation}\tag{3}\label{eq3A}$$
With just the first floor function value which is being summed, using \eqref{eq2A} gives
$$\begin{equation}\begin{aligned}
\left\lfloor\frac{2n - 1 + 2^{k+1}}{2^{k+2}}\right\rfloor & = \left\lfloor\frac{\sum_{i = 0}^{m}c_i 2^{i+1} + 2^{k+1} - 1}{2^{k+2}}\right\rfloor \\
& = \left\lfloor\frac{\sum_{i = k+1}^{m}c_i 2^{i+1} + \sum_{i = 0}^{k}c_i 2^{i+1} + 2^{k+1} - 1}{2^{k+2}}\right\rfloor \\
& = \left\lfloor\frac{\sum_{i = k+1}^{m}c_i 2^{i+1}}{2^{k+2}} + \frac{\sum_{i = 0}^{k}c_i 2^{i+1} + 2^{k+1} - 1}{2^{k+2}}\right\rfloor \\
& = \left\lfloor\sum_{i = k+1}^{m}c_i 2^{(i+1) - (k+2)} + \frac{\sum_{i = 0}^{k}c_i 2^{i+1} + 2^{k+1} - 1}{2^{k+2}}\right\rfloor \\
& = \sum_{i = k+1}^{m}c_i 2^{i-k-1} + \left\lfloor\frac{\sum_{i = 0}^{k}c_i 2^{i+1} + 2^{k+1} - 1}{2^{k+2}}\right\rfloor \\
& = \sum_{i = k+1}^{m}c_i 2^{i-k-1} + \left\lfloor\frac{(c_k + 1)\left(2^{k+1}\right) + (\sum_{i = 0}^{k - 1}c_i 2^{i+1} - 1)}{2^{k+2}}\right\rfloor \\
\end{aligned}\end{equation}\tag{4}\label{eq4A}$$
Note the numerator of the fraction in \eqref{eq4A} is greater than or equal to $2^{k+2}$ iff $c_k = 1$ and there's at least one $c_i = 1$ for some $0 \le i \le k - 1$, with the latter condition only being true if $k \gt j$. To make this simpler to handle, define a boolean type indicator function of
$$B(e) = \begin{cases}
0 & e \text{ is false} \\
1 & e \text{ is true}
\end{cases} \tag{5}\label{eq5A}$$
Using this function, \eqref{eq4A} can be simplified to
$$\left\lfloor\frac{2n - 1 + 2^{k+1}}{2^{k+2}}\right\rfloor = \sum_{i = k+1}^{m}c_i 2^{i-k-1} + c_{k}B(k \gt j) \tag{6}\label{eq6A}$$
The second floor function being summed is basically the same, but with the powers of $2$ being $1$ larger, so it becomes
$$\left\lfloor\frac{2n - 1 + 2^{k+2}}{2^{k+3}}\right\rfloor = \sum_{i = k+2}^{m}c_i 2^{i-k-2} + c_{k+1}B(k + 1 \gt j) \tag{7}\label{eq7A}$$
Using \eqref{eq6A} and \eqref{eq7A} gives
$$\begin{equation}\begin{aligned}
& \left\lfloor\frac{2n - 1 + 2^{k+1}}{2^{k+2}}\right\rfloor - \left\lfloor\frac{2n - 1 + 2^{k+2}}{2^{k+3}}\right\rfloor \\
& = \sum_{i = k+1}^{m}c_i 2^{i-k-1} + c_{k}B(k \gt j) - \left(\sum_{i = k+2}^{m}c_i 2^{i-k-2} + c_{k+1}B(k + 1 \gt j)\right) \\
& = \left(c_{k+1} + \sum_{i = k+2}^{m}c_i 2^{i-k-1}\right) + c_{k}B(k \gt j) - \sum_{i = k+2}^{m}c_i 2^{i-k-2} - c_{k+1}B(k + 1 \gt j) \\
& = \left(c_{k+1} + 2\sum_{i = k+2}^{m}c_i 2^{i-k-2}\right) - \sum_{i = k+2}^{m}c_i 2^{i-k-2} + c_{k}B(k \gt j) - c_{k+1}B(k + 1 \gt j) \\
& = \sum_{i = k+2}^{m}c_i 2^{i-k-2} + c_{k+1} + c_{k}B(k \gt j) - c_{k+1}B(k + 1 \gt j) \\
& = \left\lfloor\frac{n}{2^{k+2}}\right\rfloor + \left(c_{k+1} + c_{k}B(k \gt j) - c_{k+1}B(k + 1 \gt j)\right)
\end{aligned}\end{equation}\tag{8}\label{eq8A}$$
Next, define
$$f(k, j) = c_{k+1} + c_{k}B(k \gt j) - c_{k+1}B(k + 1 \gt j) \tag{9}\label{eq9A}$$
For $k \lt j - 1$, you get $c_{k} = c_{k+1} = 0$, so $f(k, j) = 0 = c_{k}$. With $k = j - 1$, you then get $c_{k} = 0$, $c_{k+1} = c_j = 1$, $B(k + 1 \gt j) = 0$, so $f(k, j) = c_{k+1} = c_j$. Next, with $k = j$, you get $B(k \gt j) = 0$, $B(k + 1 \gt j) = 1$, so $f(k, j) = c_{k+1} - c_{k+1} = 0$. Finally, for $k \gt j$, since $B(k, j) = B(k + 1 \gt j) = 1$, you have $f(k, j) = c_{k+1} + c_{k} - c_{k+1} = c_{k}$. In summary, then, you have $f(k,j) = c_k$ for all $k$ except for $k = j - 1$ where it's $c_j$ and for $k = j$ where it's $0$, i.e., those $2$ values are mixed around.
Note, though, if $j = 0$, then $k = j - 1 = -1$. Nonetheless, since the right side multiplier in \eqref{eq3A} for $k = -1$ is $k + 1 = 0$, so changing the starting index to $-1$ doesn't change the sum, I do this below in \eqref{eq10A} to use just one set of calculations for $j = 0$ and $j \gt 0$, and then switch back to starting at $k = 0$ near the end.
Using \eqref{eq9A} in \eqref{eq8A} and then substituting the result into \eqref{eq3A}, plus using the results & issues discussed in the above $2$ paragraphs including $c_{j-1} = 0$ and $c_j = 1$, and also what you're already noted that $c_k = \left\lfloor \frac{n}{2^{k}} \right\rfloor \bmod 2$, gives
$$\begin{equation}\begin{aligned}
n & = 1 + \sum_{k=0}^{m}\left(\left\lfloor\frac{n}{2^{k+2}}\right\rfloor + f(k,j)\right)(k + 1) \\
& = 1 + \sum_{k=0}^{m}\left\lfloor\frac{n}{2^{k+2}}\right\rfloor(k + 1) + \sum_{k=-1}^{m}f(k,j)(k + 1) \\
& = 1 + \sum_{k=0}^{m}\left\lfloor\frac{n}{2^{k+2}}\right\rfloor(k + 1) + \sum_{k=-1}^{j-2}c_k(k + 1) + c_j((j-1)+1) + \sum_{k=j+1}^{m}c_k(k + 1) \\
& = 1 + \sum_{k=0}^{m}\left\lfloor\frac{n}{2^{k+2}}\right\rfloor(k + 1) + \sum_{k=-1}^{j-1}c_k(k + 1) + (c_j)(j + 1) - 1 + \sum_{k=j+1}^{m}c_k(k + 1) \\
& = \sum_{k=0}^{m}\left\lfloor\frac{n}{2^{k+2}}\right\rfloor(k + 1) + \sum_{k=0}^{m}c_k(k + 1) \\
& = \sum_{k=0}^{m}\left[ \left\lfloor \frac{n}{2^{k+2}} \right\rfloor + \left(\left\lfloor \frac{n}{2^{k}} \right\rfloor \bmod 2 \right) \right](k+1)
\end{aligned}\end{equation}\tag{10}\label{eq10A}$$
Best Answer
By definition, $$ \mathbb{E}(f(X))=\frac{\displaystyle\sum_{j=1}^mf(j)}{m}\ . $$ Now let $$ a_{ij}=\cases{0 & if the binary representation of $\ j$ \\ &has fewer than $\ i\ $ trailing zeroes\\ 1& otherwise.} $$ Then $$ f(j)=\sum_{i=1}^ba_{ij}\ , $$ and $$ \mathbb{E}(f(X))=\frac{\displaystyle\sum_{j=1}^m \sum_{i=1}^ba_{ij}}{m} $$ But the quantity $\ \left\lfloor\frac{m}{2^i}\right\rfloor\ $ is the number of integers in the set $\ \{1,2,\dots,m\}\ $ that are multiples of $\ 2^i\ $—that is, the number of such integers whose binary expansion has $\ i\ $ or more trailing zeroes. So $$ \left\lfloor\frac{m}{2^i}\right\rfloor=\sum_{j=1}^ma_{ij} , $$ and therefore \begin{align} \frac{\displaystyle\sum_{i=1}^b\left\lfloor\frac{m}{2^i}\right\rfloor}{m}&= \frac{\displaystyle\sum_{i=1}^b \sum_{j=1}^ma_{ij}}{m}\\ &=\frac{\displaystyle\sum_{j=1}^m \sum_{i=1}^ba_{ij}}{m}\\ &= \mathbb{E}(f(X))\ . \end{align}