Both guest posts and niche edits can help with SEO when done properly. Guest posts provide fresh, relevant content and brand exposure, while niche edits add links to existing articles.
I agree with both points above, and I would decide by the page rather than the tactic alone. A guest post makes sense when you need a fresh, relevant piece where the link fits naturally and you can control the context, the anchor and the surrounding explanation. That control is also why it feels safer, as WolfyG said. A niche edit can be the better fit when the existing article is already relevant, still getting attention, and the link genuinely adds something to a point the article already makes, rather than being squeezed in. Where I would be careful is with a niche edit on a page that has drifted off topic, has not been updated in a long time, or where the new link changes the meaning of the paragraph. In that case the faster, lower-cost option can end up looking forced. So I usually ask whether the target page would still be worth linking to even without the SEO benefit. What kind of page are you weighing this for: a new page that needs context, or an established article where the link would fill a clear gap?