Depends entirely on the program. I would say that most programs can’t simply be moved to external media and run from there, but some can.
If the program depends on things installed outside of its program directory, e.g. in the system32 folder or in the registry, then it probably won’t run from a CD/DVD.
Some programs also expect to be able to write something to the folder they are run from, which will fail on a CD/DVD.
You could just try it and see if it works - try running it on another computer, where the program hasn’t been installed.