use EDD Content Restriction for restricting php in template

Since do_shortcode() needs it’s argument to be passed a string, instead of outputting the markup (e.g. echo()ing it), you should construct the markup as a string. There are many ways to do this. Below, I am using “string concatenation” (joining multiple strings into one) in order to add each relevant link to the same string which is stored in the $download_links_markup variable, then adding the shortcode tags on either side and passing the result into do_shortcode():

$download_links_markup = '<li>';

if( $href = get_post_meta( $post->ID, 'download', true ) )
  $download_links_markup .= '<a href="' . $href . '"> دانلود با لینک مستقیم</a> ';

if( $href = get_post_meta( $post->ID, 'download32', true ) )
  $download_links_markup .= '<a href="' . $href . '">لینک مستقیم نسخه 32bit / </a> ';

if( $href = get_post_meta( $post->ID, 'download64', true ) )
  $download_links_markup .= '<a href="' . $href . '">لینک مستقیم نسخه 64bit </a> ';

if( $href = get_post_meta( $post->ID, 'downloadwin', true ) )
  $download_links_markup .= '<a href="' . $href . '">دانلود نسخه ویندوز  </a> ';

$download_links_markup .= '</li>';

echo do_shortcode( '[edd_restrict id="any"]' . $download_links_markup . '[/edd_restrict]' );

I’m using some shortcuts in the if() statements, but the logic is more or less the same as the

if(get_post_meta($post->ID, 'download',true)!= ""){echo "<a href="https://wordpress.stackexchange.com/questions/408590/".get_post_meta($post->ID,"download',true)."' > دانلود با لینک مستقیم</a> ";} else { echo ""; }

conditionals used in your question.