The hypothesis tests that we conduct are never about the sample statistics but always about the true population statistics. I'll try to make it as clear as possible through this example:
Suppose we have a huge population and we have to find out the average time one spends on the internet, lets call it u. But we only have a sample of size 50 of the same population from which we found out the fact that- the average time one person among these 50 people spends on the internet is x(our observed value).
So, my population average is u which is unknown to me.
And my sample average is x which we just found out.
So now suppose we have to perform a hypothesis test if my population average is suppose N.(this is my hypothesis since it is has been assumed and N is an arbitrary number).
i.e [Ho: u = N] and so my alternative shall be [Ha: u != N].
So u can see that it is always about the true population parameter(i.e average in our case) and never ever about the sample parameter or our observed value.
On the other hand, creating a confidence interval of this sample, suppose of 95%, what we really mean to say is this- If we take repeated samples of size 50 from this population and create their respective confidence intervals, we are 100% sure that 95% of these intervals will contain my true population mean i.e u .
CI = (x + Margin Of Error, x - Margin Of Error)
You can also see this: if my null value i.e N (check the null hypothesis) doesn't fall within this interval, we can reject our null hypothesis right away.
This is the concrete idea behind these 2 methods.Don't mix them up. I hope this was helpful.