CNBC's Jim Cramer urges investors to do their homework when they seemingly get "lucky" and their stock picks rally.

That one step could be the difference between protecting those gains and giving up the ghost.

"It's very helpful to understand why a stock you like is going up or down. When you have a win, don't lazily assume that simply [you] got it right," the "Mad Money" host said. "Think about what it means if you were merely in the right place at the right time, and proceed with caution."

Cramer can often be found pounding the table about the importance of homework, or researching the company and the industry. When a stock makes big gains, investors can take it as a confirmation that their intuition about the name was right.

Cramer, however, suggested you should be skeptical.

"Maybe you're right. People are right about stocks every day, but maybe it's just a coincidence and you should ring the darn register before that coincidence goes away," he said. "If you don't understand why a stock is moving up or down, you're probably going to be very confused when it stops doing that and goes in the opposite direction. And when we're confused, we make really lousy decisions."

That's why it's important to understand rotation, which is when big fund managers sell their holdings in a particular sector to raise and invest the cash into another segment of the economy.

For example, Cramer said, stocks in the consumer packaged goods industry can roar higher even when the fundamentals don't warrant a rise in the share prices. He called Clorox and Procter & Gamble, in particular, "recession stocks," also known as defensive stocks.

Recession stocks' earnings tend to hold up even when the economy slows. Because of this, money managers are attracted to those names when they see bad economic data, he said.

"If you buy these stocks because you believe in the business, but then they go higher as part of a sector rotation, that has nothing to do with the business. Well, you still have a win," Cramer said. "But you don't want to get caught with your pants down because the market suckered you into believing that Clorox was going up based on the fundamentals, when really it was benefiting from rotation into the whole consumer packaged goods sector."