If you expand a gas adiabatically using a piston, the process is
An adiabatic process is not isentropic unless it is also reversible. To be reversible, it must be carried out quasi statically (i.e., extremely slowly) and without mechanical friction. To be quasi static the difference in pressure between the gas and its surroundings must be infinitesimal throughout the process. That is not the case if you let the gas expand freely.
However, if you simply remove the piston and let the gas expand
freely, the process is now not isoentropic. What makes these processes different?
The difference is the free expansion, although adiabatic, is not reversible, i.e., it is not quasi-static as it happens very quickly due to the pressure difference. To be isentropic, the adiabatic process must also be reversible.
But imagine that the two gases are ideal and that they expand from the
same initial volume and temperature, and into the same final volume.
Then, using the ideal gas law these states are identical, and so
should be their entropies. So why aren't they?
Although the initial and final temperature, and thus internal energy for an ideal gas, is the same, the initial and final volumes and pressures are not the same. For example, per the ideal gas law, if the volume doubles, the pressure halves. In other words, a change in internal energy of zero does not mean the change in other properties, including entropy, is necessarily zero. In this case there is an increase in entropy because of the entropy generated by the irreversible free expansion process.
Hope this helps.