Dimension of matrix vector space

For each $A$ there is $a\in \mathbb{R}$ such that for all $x \in \mathbb{R}^{n}$ we have $\mathbf{1}^T(Ax)=a(\mathbf{1}^T x)$, if and only if $A^T \mathbf{1} = a \mathbf{1}$.

So you are asking for the dimension of the space of matrices which have $\mathbf{1}$ as an eigenvector.

If we express any linear transformation in the basis with $\mathbf{1} =e_1$, then the linear transformation has $\mathbf{1}$ as an eigenvector if and only if its matrix representation in that basis has a zero in the first column in every row except the first (it can have any number in the first row, and this number will be the $a$ mentioned above).

So the dimension is $n^2-n+1$