Let $p_i$ be the $i$th prime number. For $x \in \Bbb{R}, x \gt 0$, define:
$$ \Delta(x) =\left \{\prod_{i=1}^r q_i : \{q_1, \dots, q_r \}\subset \{p_1, p_2, \dots, p_{\pi(x)}\}\right\} $$
Let $\omega$ be the little-omega function from number theory, and $\pi$ the prime-counting function.
We have the following chain of equalities:
$$ \pi(x) = \pi(\sqrt{x}) - 1 + \sum_{k=0}^{\pi(\sqrt{x})} (-1)^k \left( \sum_{f \in \Delta(\sqrt{x}) \\ \omega(f) = k} \ \ \sum_{g \in \Delta(\sqrt{x}) \\ f\ \mid\ g} 1 \right) \tag{1} $$
is another way of writing the first formula under "Algorithms for evalutation $\pi(x)$". And this in turn equals: $$ \pi(x) = \pi(\sqrt{x}) - 1 + \sum_{k=0}^{\pi(\sqrt{x})} (-1)^k \left( \sum_{g \in \Delta(\sqrt{x})} \ \ \sum_{f \in \Delta(\sqrt{x}) \\ f\ \mid\ g \\ \omega(f) = k} 1 \right) \tag{2} $$
which makes perfect sense to do so. We then have:
$$ \pi(x) = \pi(\sqrt{x}) - 1 + \sum_{k = 0}^{\pi(\sqrt{x}) }(-1)^k \left( \sum_{g \in \Delta(\sqrt{x})}{\omega(g) \choose k }\right) \tag{3} $$
That is because the range over $f \in \Delta(\sqrt{x})$ such that $f \mid g$ and $\omega(f) = k$ can be counted as ${\omega(g) \choose k}$ obviously. But the expression ${\omega(g)\choose k}$ is independent of the choice of $g' \in \Delta(\sqrt{x})$ as long $\omega(g') = \omega(g)$. And therefore we may change the sum to:
$$ \pi(x) = \pi(\sqrt{x}) - 1 + \sum_{k = 0}^{\pi(\sqrt{x})}(-1)^k \left( \sum_{\ell = 0}^{\pi(\sqrt{x})}{\pi(\sqrt{x}) \choose \ell }{\ell \choose k }\right) \tag{4} $$
And of course the canonical form of the summation would then be:
$$ \pi(x) = \pi(\sqrt{x}) - 1 + \sum_{k = 0}^{\pi(\sqrt{x})} \sum_{\ell = 0}^{\pi(\sqrt{x})}(-1)^k{\pi(\sqrt{x}) \choose \ell }{\ell \choose k } \tag{5} $$
Question. Can we use the properties of the binomial coefficient to further rearrange this summation?
If you expand $$(1+x+xy)^n$$ you get $$\sum_{i=0}^n\sum_{j=0}^n\binom ni\binom ij x^iy^j$$
Letting $x=1,y=-1$ this gives you: $$\sum_{i=0}^n\sum_{j=0}^n(-1)^j\binom ni\binom ij =1 $$
So that would mean your formula is:
$$\pi(x)=\pi(\sqrt x)-1+1=\pi(\sqrt x)$$
The problem is your very first step. You have to restrict $g\leq x.$ Not every element of $\Delta(\sqrt x)$ is $\leq x.$