Can anyone explain when does a script executed exactly? There are several information about "how scripts are executed" but no information about "when".
The script is executed during the validation of a transaction by any full node which validates it. The script denotes the spending condition, so during the verification of a transaction the node will execute the script to ensure it passes successfully and does not violate any other rules (e.g. cleanstack)