Not affecting the first line
The example output looks like there should be no newline before the first line in the file.
You can add a lookbehind check to achieve that.
:%s/^\n\@<=\ze\s*#/\r/
\n\@<=
Matches only if there's a newline before the current position, so the first line won't match. For more information see :h \@<=
That can also be done with a line check. The following regex matches only those lines that are not the first line.
:%s/^\%>1l\ze\s*#/\r/
\%>1
Matches below line 1. See :h \%>l
Here's something that should work with the updated question, that is, only add a newline before the current line, if there is no comment line before.
:g/^\%^\@<!\(^\s*#.*\n\)\@<!\s*#/norm O
^\%^\@<!
Do not match this line if the beginning of the file is before it. :h \%^
and :h \@<!
\(^\s*#.*\n\)\@<!
Only match this line if the first non-blank character on the previous line is not #.
This regex will change
#comment 1
#comment 2
statement 1
statement 2
#comment 3
to
#comment 1
#comment 2
statement 1
statement 2
#comment 3