Conflict declaration in reviews
The only problematic situtation seems to me to agree to review the paper, give it a deliberately bad review so it is rejected and then publish the own results. I personally would not review the paper in question at all because it might turn out that it is legitimate to reject it, and then it would be difficult to continue working independently.

Whether you should stop working on the problem is a more difficult question. In general I would say no unless it's something very specific with limited scope for further work. If you are reasonably sure that your work would go beyond what the other authors have done, there's no reason not to do it. You could always wait to see if the paper is published and if it is contact the authors and propose to work together.