$\underbrace{a+a+a+ \dots +a}_{\text{n times}}=a^2b$
$n\times a = a^{2}b$
$n=ab\implies n^{2}=a^{2}b^{2}$
and $\underbrace{b+b+b+ \dots +b}_{\text{m times}} = ab^2$
$m\times b = ab^{2}$
$m=ab\implies m^{2}=a^{2}b^{2}$
$\Bigg( \underbrace{m+m+m+ \dots +m}_{\text{n times}} \Bigg) \Bigg( \underbrace{n+ n+ n+ \dots + n}_{\text{m times}} \Bigg)$
$=(m\times n)(n\times m)$
$= (m\times n\times n\times m)$
$= m^{2}\times n^{2}$
$= a^{2}b^{2}\times a^{2}b^{2}$
$= a^{4}b^{4}$
So, the correct answer is (B).