I think the parentheses comments are a possible issue, but not the cause of your lights coming on at sunset, and sunrise. Your progrm will run the ELSE path any time the program is triggered (sunrise, sunset, switches controlled on) but evaluates false. Your program will always run ELSE path at sunrise and sunset, because it will always be false at those two trigger points. When that happens, the master am scene will turn on.
I understand that you may want to accomplish your goals in a single program, but this may not be possible.