Using the Intermediate Value Theorem and derivatives to check for intersections. I have the following question:
Prove that the line $y_1=9x+17$ is tangent to the graph of the function $y_2=x^3-3x+1$. Find the point of tangency.
So, what I did was:

Let's construct a function $h$, such that $$h(x)=x^3-3x+1-(9x+17)=x^3-12x-16.$$ 
This function is continuous everywhere, particularly in the interval $[0,5]$. Now, $$h(0)=(0)^3-12(0)-16=-16$$ and $$h(5)=(5)^3-12(5)-16=49.$$ So, by Bolzano's theorem, there must exist a point $c \in (0,5)$ such that $h(c)=0$. This proves that the line $y_1$ and the function $y_2$ are tangent to each other at least at one point. 
Now, we can think of the point of intersection as the point in which $h'(x)=0$. So, $$h'(x)=0 \iff 3x^2-12=0 \iff x \in \{-2,2\}.$$ Now, if either one of those two points is the point of intersection, then it must be a root of $h(x)$, so plugging them in we have $$h(2)= (2)^3-12(2)-16 = -32 \neq 0$$ and $$h(-2)=(-2)^3-12(-2)-16=24-24=0.$$ Therefore, $x=-2$ is the point of intersection of $y_1$ with $y_2$.

Now, my issue here is that I don't know exactly how to justify that what I did was actually right. In particular, I don't know why taking the difference of both original functions (constructing $h$) is a valid move and why is it that finding the points in which $h'(x)=0$ equates to finding the point of intersection between $y_1$ and $y_2$. So, my question is: if what I did was actually correct, why is it so? And if it's not, why am I wrong?. 
Thanks in advance.

I have a comment, and I know this has been looked at:
The statement involving Bolzano's Theorem, where you find that there is $c\in (0,5)$ where $h(c)=0$, implies that the graphs of the two functions intersect. It doesn't imply tangency, and it's actually a distraction, in that it gives you a point in $(0,5)$, which is quite far from the point of tangency you eventually find. (In fact, if you try using Bolzano's Theorem near the point of tangency, you must look at $h'(x)$, and not $h(x)$, since $x=-2$ gives rise to a local maximum of $h(x)$, where the function $h(x)$ is tangent to the $x$-axis.)
If you want to use Bolzano's Theorem, here's one (overly complicated) approach. First, notice that 
$$h'(-3)=15,\ \ h'(0)=-12,\ \ h'(3)=15$$
Then by Bolzano's Theorem, there exists $c\in (-3,0)$ so that $h'(c) = 0$, and there also exists $c'\in (0,3)$ so that $h'(c) = 0$. Since $h'(x)$ is a quadratic, you can find the two solutions to the equation $h'(x)=0$ by hand, namely at $c'=2$, $c=-2$  (with notation consistent with our conclusion from Bolzano's Theorem). Since it's a quadratic, we know that we have accounted for all of them. (As the other answer states, this application of Bolzano's Theorem actually serves as an unnecessary extra step, since we can find the zeroes of $h'(x)$ by hand.)
You still need the two curves to intersect at the point to have a point of tangency, which is when we use the zeroes of $h'(x)$ (the critical numbers) and check which of these are zeroes of $h(x)$. In checking, you find that $h(2) = -32$, while $h(-2) = 0$. Now plug $x=-2$ back into your starting functions $y_1$ (or $y_2$)  in order to conclude that you have a single point of tangency at $(-2,-1)$.

Of course, the less complicated alternative is to check that $h(x)$ has a double-root at $x=-2$, which it does, since  $h(x) = (x+2)^2(x-4)$,  which guarantees a point of tangency there. (This method is exactly that of the other answer, where you find roots of $h(x)$, and then check to see which of those  is a root of $h'(x)$.)
