As an example, let's take $d=2$ and $n_1 = 3, n_2 = 4$. We want a polynomial $P$ of degree 2 such that $P(3) = P(4) = 0$, and we want $P$ to be monic. So $P$ will have the form $$P(x) = x^2 +bx + c$$ for some coefficients $b$ and $c$ that we don't know yet. But we do know that $$\begin{align} P(3) & = 3^2 + 3b + c \\ & = 3b + c + 9\\&=0,\end{align}$$
and similarly that $P(4) = 4^2 + 4b + c = 0$. This gives us two equations in $b$ and $c$, which we can solve:
$$\begin{array}{crrc}
3b & + c & + 9 & = 0 \\
4b & + c & + 16& = 0
\end{array}
$$
To get: $$\begin{align}b&=-7 \\ c &= \hphantom{-}12\end{align}$$
so our polynomial $P(x)$ is exactly $$P(x) = x^2 -7x + 12.$$
There are many other second-degree polynomials that have $P(3) = P(4) = 0$, but all of them are multiples of $P$, and none is monic. For example, $3x^2 - 21x + 36$ has this property, but it isn't monic. In fact it's just $3P$.
Now how do we solve this problem for higher-degree polynomials? Notice that $P(x) = (x-3)(x-4)$. In this form it's obvious that $P(3) = 0$, since $x=3$ makes the $x-3$ factor equal to $0$, and that $P(4) = 0$, since $x=4$ makes the $x-4$ factor equal to $0$. So it's easy to see how to generalize this: If we want a 4th degree monic polynomial $Q$ where $Q(1) = Q(3) = Q(6) = Q(7) = 0$, for example, just compute $$Q(x) = (x-1)(x-3)(x-6)(x-7)$$ and this will have just the properties we want.