I won't give a full answer, but a way to attack the problem of computing the dimensions of the cohomology groups with compact support in the special case $n=2$.

Let $X_k = \{ (A,B) \in \mathcal{M}_m(\mathbb{K}), \ A B = 0, \ \textrm{rank}(B) = k\}$. Then, in the case $m=2$, your $X$ is the disjoint union of the $X_k$ for $k \in [0, \ldots, m]$. I will compute the number of points over $\mathbb{F}_{q}$ of $X_k$ by describing $X_k$ as a sort of iterated fibrations.

Let $p : X_k \longrightarrow \mathrm{Gr}(k,\mathbb{F}_{q}^m)$ which sends a pair $(A,B)$ to the image of $B$. The target of $p$ has cardinality $\binom{m}{k}_q$ (where $\binom{m}{k}_q$ denotes the $q$-binomial coefficient).

The fiber of $p$ over $L$ is the variety:
$$ p^{-1}(L) = \{(A,B) \in \mathcal{M}_m(\mathbb{F}_{q})^2, \mathrm{Im}(B) = L, \ L \subset \mathrm{Ker}(A) \}.$$

It easy to see that the fibers over different $L$ are all isomorphic. Furthermore, we have a natural projection
$$q: p^{-1}(L) \longrightarrow \mathrm{Hom}(\mathbb{F}_q^m,L)_{\mathrm{rank} = k}$$ sending a pair $(A,B)$ to $B$.

Let us compute the cardinal of the target of $q$. We have a natural projection:

$$r : \mathrm{Hom}(\mathbb{F}_q^m, L)_{\mathrm{rank} = k} \longrightarrow \mathrm{Gr}(m-k,\mathbb{F}_q^m)$$
which sends an element of $\mathrm{Hom}(\mathbb{F}_q^m, L)_{\mathrm{rank} = k}$ to its kernel. The fiber of $r$ is exactly $\mathrm{GL}_k(\mathbb{F}_q)$. Since the cardinal of $\mathrm{GL}_k(\mathbb{F}_q)$ is $\prod_{j=0}^{k} (q^k-q^j)$, we deduce that:

$$ \mathrm{card}(\mathrm{Hom}(\mathbb{F}_q^m, L)_{\mathrm{rank} = k}) = \binom{m}{k}_q \prod_{j=0}^{k} (q^k-q^j).$$

In order to find the cardinal $p^{-1}(L)$, we then just have to find the cardinal of $q^{-1}(B)$ for some $B \in \mathrm{Hom}(\mathbb{F}_q^m, L)_{\mathrm{rank} = k}$ (all such $q^{-1}(B)$ are isomorphic). But we have:

$$ q^{-1}(B) = \{A \in \mathcal{M}_{m}(\mathbb{F}_q), \ L \subset \mathrm{Ker}(A) \} = \mathrm{Hom}(\mathbb{F}_q^m/L,\mathbb{F}_q^m).$$
We deduce that the cardinal of $q^{-1}(B)$ is $q^{(m-k)m}$. This gives:
$$\mathrm{Card}(p^{-1}(L) = q^{(m-k)k} \binom{m}{k}_q \prod_{j=0}^{k} (q^k-q^j).$$
This implies that:
$$ \mathrm{Card}(X_k) = q^{(m-k)k} \left(\binom{m}{k}_q \right)^2 \prod_{j=0}^{k} (q^k-q^j),$$
and finally:

$$\mathrm{Card}(X) = \sum_{k=0}^{n} q^{(m-k)k} \left(\binom{m}{k}_q \right)^2 \prod_{j=0}^{k} (q^k-q^j).$$

From this formula and the Weil conjectures (and a computer), you can probably find the dimensions of the cohomology groups with compact support of $X$ (this is the case $n=2$).

**EDIT** : the formula:
$$ Z(X,t) = \dfrac{P_1(X,t) \times \ldots \times P_{2d-1}(X,t)}{P_0(X,t) \times \ldots \times P_{2d}(X,t)}$$
is valid even if $X$ is not projective and singular, provided we interpret $P_i(X,t)$ as the characteristic polynomial of the Froebenius acting on compactly supported étale cohomology (see Theorem 29.8 in http://tomlr.free.fr/Math%E9matiques/Milne%20-%20Lectures%20on%20Etale%20Cohomology.pdf). 

The computation I did dtermines entirely $Z(X,t)$. Hence, the uniqueness of the factorization of $Z(X,t)$ as a product as above guarantees that the dimensions of the compactly supported cohomology groups of $X$ can be derived from the above formula. Of course this derivation is not easy, but it can certainly done using a computer algebra system. 

**EDIT EDIT** As Will Sawin points it out, the uniqueness is not necessarily valid in the singular context, so it requires some more work to get the Betti numbers from the Zeta function.