you don't always lose on the river, but you likely remember the times you lose on the river more often than you do when you were behind on the flop or the turn.
my theory is that losing on the river is more impactful for a lot of players, most likely because it ends all hope of improving on a later street since the hand is over. when you're behind on the flop or on the turn, you still (in most situations) have some equity left to make a winning hand in the end. that doesn't happen on the river.
there is also a possible situation of players, who are ahead, not taking into account how their/their opponent's equity hand changes as more cards come out. yes, you might have the best hand on the flop and on turn, but if the turn gives your opponent more equity, then the
odds of them improving on the river increases. and, therefore, you losing on the river will happen a lot more often than you originally expected.
so, all of this has to be taken into consideration but, the main thing to remember is: just because you're losing when you're (way) ahead doesn't mean you're doing any wrong. it's just how things worked out for you. poker is a game of decisions and not results. results are secondary because you don't make profits off of results, you make profits off making proper decisions. results will come naturally if you get your hand in ahead more often than not.