If I saw a research result similar to mine from my PC duties, should and how should I contact the authors? It happened many times that I saw a paper submitted to a conference where I am on the PC, or a journal where I am editing, and such paper had something similar to what I am working on. The situation is worse when I already have something better. 

Of course I should declare a conflict of interest and should let others handle the paper. But I always wonder whether I should contact the authors.


If I don't contact the authors, they might doubt the independence of my paper from theirs. This will be worse if their paper was not published at that point (perhaps it got rejected several times). 
If I do contact the them, they may feel that I push them to do something they don't want to, such as making their paper public or collaborating with me.


There are more pros and cons, but I will stop here to keep the question simple.
In my experience it is not a conflict of interest to be working on something similar.  As @TheWanderer said, that's exactly why you end up reviewing such papers.  Nor is it appropriate to use your knowledge of their submission to contact them.  

Generally speaking, as a program committee member, you should treat what you see there as confidential, and treat the fact that you are reviewing it as confidential as well.  If you choose to provide comments in your review, based on your own experience, that can help them improve their paper, that's great.  If you feel like your personal knowledge of the area is such that to comment on it you would be revealing unpublished information of your own, you need not include such comments.  You should simply evaluate their work in the context of whatever is public at the time they submit.  If someone else publishes something that makes their work obsolete, and it appears between the time of submission and the time their own work would appear, it's rotten luck but I think they would still need to treat the soon-to-be-published work as having precedence.  

The same applies as a reviewer for a journal of course.  

In some fields there may be exceptions.  For instance, there are open-access journals with public, attributed reviews.  But in CS these seem quite rare.