The curve shows :
- x goes 1 to right
- y goes up by 3
the SLOPE is defined as the ratio of rise to the step
SLOPE = rise/step = 3/1 = 3
Now that :
- Horizontal line has
SLOPEof 0. - Vertical line has
SLOPEof undefined.
It makes sense for me to imagine horizontal line has SLOPE of 0 since there is no rise at all. But why the vertical has SLOPE of undefined.?

Because $dx$ (step) for a vertical line is 0 and the expression for slope $$m=\frac{dy}{dx}$$ results in the bogeyman of mathematics, division by zero. That's why.
However, in some cases we define the slope of a vertical line as $\infty$. This implies $\frac 1{\infty}=0$ and vice versa, and is useful in projective geometry among other areas of mathematics.