@Neeru, I observe 2 aspects in your question.
1. They criticise immediately
2. They criticise everything
One should always keep in mind that there can be people who are well-wishers and do keep very good knowledge of the subject. They will criticise the subject if they know that what the doer is doing is wrong. If they continue for even more time doing the same thing, the creation of doing will go absolutely bad and worthless. Thus, they will immediately warn you and keep on warning you again and again. If they have the right to stop you, they will stop you.
This is healthy criticism. Thus in your query itself, please try to filter out these people. For example, a class teacher will criticise and stop you from doing a wrong way of study.
The second kind is those people who, as you mention, act like knowing everything and will go on giving their views about the subject. As you rightly said, they think they know everything and their input is needed by others.
Here also, you may want to divide people into 2 types.
One are those who do this unknowingly
While others are those who do this knowingly
People who do this unknowingly, also do not expect anything in return. They do not even expect a comment. But keep a watch on what they say, sometimes, you might find out something which is really good.
People who do this knowingly, have vested interests in their comments. These vested interested are most of the times, to pull you back from progress. This is because criticism is good, but criticism on everything is not a good sign.
In the end, if you think of how to stop someone from criticising, you will never succeed. This is simply because we are not here to find out ways to stop others.
But a much easier way is to improve yourself, in understanding how you can filter things and absorb only the ones that will lead to progress in yourself. And however one tries to criticise, they will become silent, once they see the end product of what you had been toiling for.
Self-discipline brings success; but restraints too binding bring self-defeat.