let me assume $A$ is invertible, then you ask when $$\det(1+X)=1+\det X,\;\;X=A^{-1}B $$ so if $X$ has eigenvalues $x_n$$x_i$, $n=1,2,\ldots N$$i=1,2,\ldots n$, you would need $$\prod_{n}(1+x_n)=1+\prod_n x_n$$$$\prod_{i}(1+x_i)=1+\prod_i x_i$$ basically you can take arbitrary values for $x_1,x_2,\ldots x_{n-1}$ and then the only requirement is that $$x_n=\frac{1-U}{U-V},\;\;U=\prod_{i=1}^{n-1}(1+x_i),\;\;V=\prod_{i=1}^{n-1}x_i$$