The given language is regular language (a+b)*
$\rightarrow$ You may think that $n_{a}(P) = n_{b}(Q)$ requires comparison and for comparing them we need stack and stack +FA = PDA.
$\rightarrow$ so it is not regular.
$\rightarrow$ But here the thing is
$\rightarrow$ We adjust the input string according to our requirement and divide them according to the need of the question such that
$\rightarrow$ $n_{a}(P) = n_{b}(Q)$ condition satisfies.
For eg :-
1. aabbab is the input string.
we can divide the string like P = aab and Q = bab.
=> $n_{a}(P) = n_{b}(Q)$ = 2.
2. aaa is the input string.
we can divide the string like P = $\epsilon$ and Q = aaa.
=> $n_{a}(P) = n_{b}(Q)$ = 0.