tex has local and global scope as determined by groups ({...} and \begin...\end in your examples (\begin...\end forming a group as they are macros that expand to use of the tex primitive \begingroup and \endgroup group constructs.)
Commands can be defined to have local or global action but the ones you show are local, a global assignment is not restored when the group ends.
However your confusing output is caused by user error, \flushright is not intended to be used as a command (the command form is \raggedleft) it is the implementation of the start of the \begin{flushright} \end{flushright} environment.
TeX's linebreaking is optimised over a paragraph, using the settings at the end of the paragraph.
The important thing here is that (unlike \raggedleft) \flushright executes \par so ends the previous paragraph so:
In the first case the paragraph is finished, and set with normal settings then locally huge font and ragged setting is set up but discarded at } before being used.
In the second case Huge fonts and baseline is set up, so the paragraph is set with a huge baseline when the \par in \flushright is executed.
In the third case, the paragraph is set with the normal settings by the implicit \par at the blank line, and so the local settings in the following group are not used at all.