Re-election does not typically increase your "number" in the presidency. Washington was the first president and not the 2nd even though he won re-election. Johnson is therefore 17th because 16 men occupied the office before him: https://en.m.wikipedia.org/wiki/List_of_Presidents_of_the_United_States
The only exception to these numbers is Grover Cleveland, the only President to serve non-consecutive terms, and who is therefore both the 22nd and 24th president.