Connected components of a given subspace of $M_{n \times n}(\mathbb{R})$. This question is motivated by this question, which gave me quite a headache today.

Context:
I posted originally what I thought was a quick proof using the derivative of the given function. It was intended to be a straightforward answer using a well-known strategy of proving something is constant and equal to some other thing by proving its derivative is zero and you are in a connected set. But I came across an issue: I didn't realize that I was not in a connected set, as the domain of definition of my function had to take into account the inverses I was considering (see here). I managed to go around this issue (although at the cost of simplicity), but one of my initial attempts to solve my blunder was to try to pinpoint the connected components of the set $\mathcal{D}$ I was considering. I wasn't able to solve this issue (trying to show it was path-connected got me troubled in a lot of possible cases for the matrices). Hence, this present question arose

What are the connected components of the space $\mathcal{D}=\mathcal{A} \cap \mathcal{B}$, where $\mathcal{A}=\{A \mid \exists A^{-1}\}$ and $\mathcal{B}= \{B \mid \exists (I+B)^{-1}\}$?
 A: Note that the conditions are $\det(I+A)\neq 0$ and $\det(A)\neq 0$, so this subset is open, so that it is locally pathconnected, and the connected components coincide with the path connected components. There is a dense subset that is diagonalizable, simply the matrices with distinct eigenvalues. Then note that $det(\lambda I+A)$ is invariant under conjugation, so that conjugation is a dijection on this space. Note that if $UBU^{-1}$ is diagonal, then letting $C=diag(-1, 1, \dots 1)$, then $CUB(CU)^{-1}=CUBU^{-1}C=UBU^{-1}$ is diagonal, so we can always assume that our diagonalizing math is of positive determinant, and thus we have that every diagonalizable matrix in $D$ is in the same component as a diagonal matrix.
Now we can get to work, and we assume that $n>1$. Take a continous function $f:D\to \{0, 1\}$. Then $f$ is determined by a dense subset, and by the above remarks, by the diagonal matrix. Then the conditions specify that that the diagonal elements are all $\neq 0, -1$. Further conjugation by elementary matrices allows us to assume the diagonal elements are ordered by size. Now by scaling, we may assume that all entries are $-2$, $-1/2$, and $1$. Not denoting the rotation matrix between the $e_i$, $e_j$ plane of angle $\theta$, as $R^{ij}_{\theta}$, we see multiplication by $(1/2)R^{ij}_{\theta}$ can change two $1$'s to $-1/2$'s and $2R^{ij}_{\theta}$ can change two $1$'s to $-2$'s. Thus there is atmost $4$ connected compotents, since every $f$ is determined by $4$ matrices. Now we have a function $(sign(det(A)), sign(det(A+I))):D\to \{0, 1\}^2$, and it can be explicitly checked that it is surjected, by taking the matrices that are left by the above procedure.
Thus there is $4$ connected components, determined by $(sign(det(A)), sign(det(A+I)))$.
