with or without ":" ? why is this "set" command not working ?

This

:local wan1 "ether4";
/interface ethernet;
set [ find default-name="$wan1" ] comment="$wan1" name="wan1";

Equals this

:local wan1 "ether4";
/interface ethernet set [ find default-name="$wan1" ] comment="$wan1" name="wan1";

The “set” command in this case is part of a Terminal Command which does not need the “:”.

A script command set would need the “:”, example..

:local wan1;
:set wan1 "ether4";
/interface ethernet set [ find default-name="$wan1" ] comment="$wan1" name="wan1";

The main reason to write the terminal command as you did would to set multiple variables under the same folder. example..

:local wan1 "ether4";
local wan2 "ether5;
/interface ethernet;
set [ find default-name="$wan1" ] comment="$wan1" name="wan1";
set [ find default-name="$wan2" ] comment="$wan2" name="wan2";