Is a function that has a vertical tangent line a function?
At, $a$, the function has a "infinite slope" or vertical tangent line. If the slope of the tangent line is considered to be the instantaneous rate of change, at that point, the function increases "straight up".
Since the function increases "straight up", the next point would be right above the previous point. Since a function can only have one value in the range per domain, and this function would at least two range values (the points right above each other) for the same domain value, wouldn't it violate the definition of a function?
Note that I understand that the function doesn't actually consist of discrete points, but is instead continuous. However, if the function is considered to consist of points infinitesimally close together, wouldn't the next "infinitesimally" far apart point be right above the previous point?
Having a vertical tangent line does not imply a graph does not represent a function. It may be easier to consider the example of a horizontal tangent line. For example: $$y=x^3 \implies y'= 3x^2$$
At $x=0$, we have a horizontal tangent line. Following the logic from the OP, the points just to the right and left of $x=0$ would have the same $y$ coordinate ($0$). However, we know from pre-calc that $y=x^3$ is a one-to-one function, which contradicts those other points having the same $y$ coordinate.
The same intuition applies to the vertical example.
Why is this? Essentially, it's because you're taking a limit. The slope of the tangent line could be thought of as the slope at one point, not between $2$ points...
Someone else may be able to give a more rigorous reasoning, but I hope this provides some intuition...
Minor nitpick: all lines are straight, so a better term for what you're looking at would be "vertical" tangent line.
Now, tangent lines only make sense for differentiable functions, so you shouldn't expect that tangent lines are going to tell you whether or not something is a function. What your example would show is that such a function is not differentiable at the point where you have the vertical tangent.
However, if the function is considered to consist of points infinitesimally close together, wouldn't the next "infinitesimally" far apart point be right above the previous point?
Nope. In the most reasonable formulation of infinitesimals for this sort of intuitive reasoning, it turns out that any point infinitesimally close to (but distinct from) $P$ still has $x$ different from (but infinitesimally close to) $a$.
As an aside, even if your claim were true: that when you change the problem to one with infinitesimals you would get two points on the curve with the same $x$ coordinate, you still haven't proven that $f$ is not a function: the condition that $f$ is a function is not expressed in terms of infinitesimals. You would need some additional argument to argue that the observation made in the changed problem really is telling us something about $f$.