How can I create comment on node insert?
I guess you're hitting some edge case in \Drupal\comment\CommentStatistics::create(), which is called in comment_entity_insert(). The code assumes that there is no comment yet when that is called. Which is an assumption that you are breaking, probably because your module gets called first.

That's arguably a core bug, you could open a bug report and try to fix it there to do a merge query. That said, as a workaround, make sure that your hook is called later than comment. You will have to implement hook_entity_insert() instead of node as that is apparently called later (by default, hooks are stored by modules by weight, name, so C should be before N).

PS: You should enable verbose error logging and check the full backtrace of that error. That can often help with understanding what's going on.