Key space math clarification
the key space should be 5


Something is $5$, but that's not the key space.

The key space is the set $\{\mathtt{K1},\mathtt{K2},\mathtt{K3},\mathtt{K4},\mathtt{K5}\}$. We'll note it $\mathcal K$.

The size of the key space (or key space size for short) $\|\mathcal K\|$ is $5$.

The size of the key (or key size for short) in bits, that we'll note $k$, is the base-2 logarithm of the size of the key space, that is $k=\log_2(\|\mathcal K\|)$.
Here $k=\log_2(5)=\log(5)/\log(2)=2.3219\ldots$ bit.


  But some articles I've read say you do do $k^2$.


Read again: probably the article says that the size $\|\mathcal K\|$ of the key space $\mathcal K$ is $2^k$, where $k$ is the size of the key in bits. That is, $\|\mathcal K\|=2^k$. Or equivalently, $k=\log_2(\|\mathcal K\|)$.