As already mentioned, we don’t take h=0 in this process ever. We take the limit as h->0.
However, have you come across the concept of continuity? It tells us that a function is continuous at a point x=a if and only if the limit of our function as x->a turns out to be the same as our function evaluated at x=a.
Thus we can use this fact and say that if your simplified expression 2x+h is continuous in h, then the limit is exactly the same as just substituting in h=0 in the end. This is why it looks like we set h=0.
As a counter-example, consider something like the continuous function f(x) = |x| = x*sign(x) where we have the discontinuous function sign(x) = -1,0, or 1 depending on whether x is negative, zero, or positive, respectively.
We see that f’(x) = limit as h->0 of [ (x+h) * sign(x+h) - x * sign(x) ] / h
We can simplify this to: f’(x) = limit as h->0 of [ x * (sign(x+h) - sign(x)) ] / h + sign(x+h)
Consider some cases , we treat h to be so small that x+h and x have the same sign …
* If x>0 then sign(x+h) = sign(x) = 1 so f’(x) = limit as h->0 of 1 which is a constant (so continuous in h) hence we can set h=0 and see that f’(x) = 1.
* If x<0 then sign(x+h) = sign(x) = -1 so f’(x) = limit as h->0 of -1 which is a constant (so continuous in h) hence we can set h=0 and see that f’(x) = -1.
* If x=0, then f’(x) = limit as h->0 of sign(h). Now this sign function is not continuous in h (precisely at h=0) so we cannot substitute h=0 into here to get the limit. In fact, because our limit depends on whether h is positive or negative, it means that it does not exist.
In this example we have shown that the continuous function f(x)=|x| is not differentiable at x=0, but it has a gradient of +1 for values x>0, and gradient -1 for values x<0.