Imagine being asked to choose 5 numbers that sum to 100. For simplicity sake you say 20, 20, 20, 20. Before you utter the 5th number I ask you to stop and say that I know your 5th number is 20 as well. This is because the first 4 numbers chosen by you summed up to 80 and the condition was to chose 5 numbers which sums to 100.
So 100 -80 = 20. The fifth number is 20.
The fifth number in a sense chose itself due to the condition specified.
You see you had 4 degrees of freedom alone. All one needed was the first four numbers. This also intuitively explains the n-1. Here n being 5 and n-1 =4.
You lost one degree of freedom to the condition of “5 numbers should sum to 100”
In other words you had 4 degrees of freedom.