Here's a quick example where you're ahead on the flop, but (counter-intuitively) are not expected to be be best at showdown.
Board: Q

2

5
*******Equity*****Win*****Tie
MP2****45.62%**45.62%***0.00%*{ QsJs }
BU*****54.38%**54.38%***0.00%*{ AhKh }
You have TP with QJ, but villain with AKs is the favourite to win, at least at this point. If villain showed you his cards, you'd obviously bet as you have the best hand. If he shoves, you'd call. Although you'll only win the hand 45% of the time, the dead money would make it just about break even.
If villain merely flatted with his monster draw (NFD+ 2 overs), then you'd see a turn card. If it was a blank, QJ would suddenly become a big favourite, with about 65% equity. You'd obviously bet again. If we ignore implied odds, villain would be making a mistake if he called more than half pot. Thus we see it's better for the drawing hand to get the money in on the flop when he's a favourite, instead of waiting till the turn when he'll be a big dog.