There are no generic boundary conditions that guarantee that the interpolating spline reproduces a sampled polynomial.
On the other hand, any $p-1$ conditions (where $p$ is the spline polynomial degree), which are taken from the original interpolated polynomial, will produce a spline that reproduces the original polynomial.
For example, consider a cubic polynomial $P(x)$, which is interploated at $n+1$ points $(x_i, y_i)$, $i=1,..,n+1$, where $y_i = P(x_i)$.
Let $S(x)$ be the interpolating cubic spline and denote by $S_i(x) = a_i x^3 + b_i x^2 + c_i x + d_i$ the $i^{th}$ polynomial segment in the spline, over the knot interval $[x_i, x_{i+1}]$ (there are $n$ such polynomial segments).
The unknowns that completely define the spline are the $n$ tuples $(a_i, b_i, c_i, d_i)$, for a total of $4n$ unknowns.
Then:
- There are $n$ constraints of the type $S_i(x_i) = y_i$.
- There are $n$ constraints of the type $S_i(x_{i+1}) = y_{i+1}$.
- There are $n-1$ constraints of the type $S_{i-1}'(x_i) = S_{i}'(x_{i})$ (for $i=2,..,n$ inner knots).
- There are $n-1$ constraints of the type $S_{i-1}''(x_i) = S_{i}''(x_{i})$ (for $i=2,..,n$ inner knots).
All in all, there are $4n-2$ constraints, so there remain $2 = p-1$ degrees of freedom to be filled by two additional constraints.
If, for example, we add the constraints that $S_1'(x_1) = P'(x_1)$ and $S_1''(x_1) = P''(x_1)$,
then $S_1(x)$ is totally defined and is identical to $P(x)$ (since the two additional constraints + the end point constraints of type (1) and (2) above uniquely defnine a cubic polynomial).
Furthermore, since $S_1$ is now defined and is identical to $P$, the constraints of type (3) and (4) for segment $S_2$ force it to be identical to $P$ as well (again since the first and second derivatives at the start point are identical to $P$ and so are the values at $x_2$ and $x_3$).
We can continue this argument to $S_3$ and onwards..
From this argument, we see that the constraints "propagate" to all the spline segments $S_i$, and therefore $S(x)$ reproduces $P(x)$.
On the other hand, if the additional constraints are not identical to $P$ then already the first segment $S_1(x)$ will not reproduce $P(x)$.
This is why, for example, the constraint $S_1''(x_1)=0$ (as in the natural spline in your counter example), will not reproduce $P(x)$
(except for the special case where $P''(x_1)=0$ and $P''(x_{n+1})=0$, which happens only when $P(x)$ is a degenerate cubic polynomial where $a=b=0$, i.e., $P$ is a straight line).
The above arguments can be generalized to any polynomial degree.
Furthermore, there is nothing special in $S_1$ and one can constrain any segment $S_i$ by constraints
from the original polynomial $P(x)$ (e.g., derivative values at endpoints) and these will propagate to all the spline segments.
Actually,
we can learn this from the uniqueness of the spline interpolation (for a given set of $(p+1)n$ constraints).
Since the original polynomial satisfies all the spline constraints and the additional $p-1$ constraints, it is thus a particular
case of an interpolating spline and the result is immediately derived from the spline uniqueness.