Proving that all roots of a particular polynomial are real
Hint
Note that $$P(-a_m)=2\prod_{k=0}^n (b_k-a_m)=2\prod_{k=0}^{m-1} (b_k-a_m)\prod_{k=m}^n (b_k-a_m)$$which is positive when $m$ is even and negative when $m$ is odd. Also$$P(-b_m)=\prod_{k=0}^n (a_k-b_m)=\prod_{k=0}^{m} (a_k-b_m)\prod_{k=m+1}^n (a_k-b_m)$$which is positive for odd $m$ and negative for even $m$.
Hint. We first notice that the degree of $P$ is $n$. Then, for $i=0,\dots,n$, we have that $$P(-a_i)=\prod_{k=0}^{n} (-a_i+a_{k})+2\prod_{k=0}^{n} (-a_i+b_{k})\\=0+2\underbrace{(-a_i+b_0)}_{<0}\dots \underbrace{(-a_i+b_{i-1})}_{<0}\cdot\underbrace{(-a_i+b_{i})\dots (-a_i+b_n)}_{>0} $$ that is the same sign of $(-1)^i$. Morever $$P(-b_i)=\prod_{k=0}^{n} (-b_i+a_{k})+2\prod_{k=0}^{n} (-b_i+b_{k})\\=\underbrace{(-b_i+a_0)}_{<0}\dots \underbrace{(-b_i+a_{i})}_{<0}\cdot\underbrace{(-b_i+a_{i+1})\dots (-b_i+a_n)}_{>0}+0$$ that is the same sign of $(-1)^{i+1}$. Now it remains to apply the the intermediate value theorem (as you already noted in your question).