I understand the concept that we have free will. But there are punishments for transgressing the commandments.
Does the existence of the punishments remove the free will and free choice?
In order to avoid confusion of what you mean to imply with your question, first let me define two distinct types of freedom.
The first is the ability to choose - the faculty that enables you to do as you please, as opposed to being a robot whose actions are controlled by an other.
The second is the right to choose - being given the freedom to decide what is good and what is bad. Self-determination of what would be a good path would be called free choice, i.e. your choice is not assessed by anyone but yourself.
In any case, punishment does not affect either. The prohibition is what takes away your right to choose - you have an Other telling you said action is not within your rights to do it. The punishment that comes with doing it is not what made you not have the right to decide to do it. The punishment also does not take away your ability to perform the action.
If divine punishment were miraculously administered immediately then yes, but that is not the case as we can see and as scripture notes:
"If you see oppression of the poor and deprivation of justice and righteousness in the province, wonder not about the matter, for the Highest over the high watches over them, and there are higher ones over them" (Ecclesiastes 5:7).
Although the punishment would deter one from sinning, the sin itself is pleasurable. So the benefit one gets from the sin and the punishment is cancelled out eventually. If there was no punishment, then with only the fun result of sinning, one would be driven to sin and also lose free will in a sense.
The will is free in the sense that the cosmic forces supporting and opposing the drive to do sin are balanced.
The catch is that the punishment is not apparent and only those who believe in it will experience that half of the balance.