How to create a self-extracting file (* .exe) and set a password for the archive with WinRAR

When downloading documents or games from the internet, we often encounter cases where the downloaded file is in a self-extracting format (* .exe) or has a password protected? So how are they made? What software to use to do it?