Why do we use n-2 degrees of freedom in a two tailed t-test for hypothesis testing?

Is it because we are doing a 2-tailed test?

What is the logic behind using n-2 degrees of freedom and not just ‘n’ degrees of freedom?

Thank you

you lost 2 degrees bcos 1) mean

  1. std dev

was calculated with the n points of data