... you cannot do anything about it. It sometimes happens. And sometimes it comes so fast, that you cannot react properly on it. But mostly, you notice that you have to cough before you do it.
Especially, you can put something in front of your mouth. Even if it appears like nothing leaves your mouth, when coughing, you spit some stuff, even if you do not see it. That is why children are told to put their hands in front of their mouths.
Usually, this is not a good idea, since you will touch a lot of other stuff with your hand. One should better use either some tissue, or your elbow.
However, it appears that many people have not been told to do so. When sitting in trains or busses, especially in winter, I see people szneesing and coughing, without putting something in front of their mouth, almost every time.
This is disgusting! And it is antisocial - it makes other people sick!