Another way to look at the problem is that a comma should be printed before every string except the 1st one, so create a variable called "comma" and initialize it to the empty string and set it to "," after the first string is printed.
Not tested but you get the idea:
{assign var="comma" value=""}
{foreach from=$all_states item=state key='key'}
{foreach from=$preview_data.applicable_states item=pre key='index'}
{if $state.id == $pre} {$comma}{$state.state_name} {assign var="comma" value=","}{/if}
{/foreach}
{/foreach}