Spot a possible improvement when reviewing a paper
Contacting the authors directly is a terrible idea. Don't go there. Contacting the editor with a question or request is fine. If you contact the authors directly and they interpret it as a form of poaching and complain to the editor, you may lose the opportunity to review in the future.
But the &quot;best&quot; option isn't to join the paper. It is to give your best review, pointing out what you think has been missed and asking for major revisions if that is what it would take.
Tell the editor that you would be willing to work with them on the improvement with permission and await what happens. You may not get a co-authorship (I doubt you will) and your advice might even be attributed to the anonymous reviewer, but that is pretty natural.
You will have contributed to the advancement of the art.