Good question. Are you losing because you have to fold or because your opponent hits a lucky card? Assuming it's because of a card, I suggest learning about outs well. An "out" is a card that somebody can hit to beat you. Roughly speaking, the percent chance an opponent will hit an out with one card to come is:
Number of Outs x 2
So here's an example. You get it in with top pair to your opponent's diamond flush draw at the turn. There are thirteen diamonds and with two on board and two in his hand, that leaves 9 left. So around 18% of the time, he will make his flush on the river.
If often feels like players are hitting draws much more often than these numbers say, but that's because we naturally remember the times we get bad-beated much better than the times we have a strong favorite that holds up. Knowing and remembering the numbers will hopefully help!