I am reading about hypothesis testing and have encountered Z test and T test. I have understood both the tests and their usage. One part that is not still clear is why does Z test does not depend on Degrees of freedom where as other tests like T test, chi-square depend on degrees of freedom.
This is because Z-test uses standard normal distribution that is set and does not change with number of observations. While the other distributions actually change their shape with number of observations.
For example on the graph below you can see comparison of students t distribution for t-test and standard normal distribution for z-test for 3 cases where number of observations is $n=2,5,8$ respectively.
In all three cases the z-test will just use the same standard normal distribution, but in the case of t-test the shape of t-distribution changes with number of observations and consequently degrees of freedom (for simple one sample t-test degrees of freedom are $df=n-1$.)
The reason why the distribution is actually made in a way that it changes its shape depending on df is that it is based on estimation of the variance from the sample which leads to greater uncertainty and a more spread out distribution. This is especially true in small sample and, as can be seen from picture below the t-distributions heavier tails. Also actually as you increase your sample size to infinity students t distribution converges to standard normal distribution because as the number of observations approach infinity also sample variance will approach the true population variance.