So, with our function f(x) = 2x, let's make x = 3 and see what happens;
The gradient will equal [2(3.001)-2(3)]/0.001 which equals (6.002-6)/0.001 which is also 0.002/0.001 which is equal to 2, notice how the coefficient of x (the gradient) is the same as the gradient we just found? Now since a simple function like 2x already has its gradient known its not that helpful in this case, but when you get to functions with curves like x2, it lets you find the gradient at any x value.
Im sure you already know all these things, but all the better, as the same applies for trig functions! If you're still having some trouble id recommend going through what I just did but with the function sinx, and you will notice if you keep plotting gradients on a graph that it actually makes a cosine graph, at your current level you shouldn't need to worry too much about why this is, just remember that it is!