If these analysts believed that the market truly was at a peak and was destined for a crash soon, why wouldn't every stock be marked as a sell? The market as a whole is just one factor that goes into these recommendations. The potential for future growth, relative strength in the sector, and other factors play a part as well.
These recommendations are also geared more towards long-term investors, not day traders looking to time the market.
For this specific case, in economic downturns (e.g. recessions), discount retailers like Wal-Mart would probably fare better than higher-end retailers in the same space like Whole Foods. So their recommendation may be that the stock will perform better in the long run than its peers. Yes it might have a downturn along with the rest of the market, but those are short-term events. Over 5, 10, 15 years their prediction may be that Wal-Mart at least survives and then thrives coming out of the other side, versus other retailers that might not survive a downturn.
If someone has an investment in Walmart at this time, should he protect his investment with PUT options or he should sell them?
IF you use these ratings as your barometer, then you should buy more. If you think there's a chance of a downturn, then sure, using put options would be a way to insure your investment. But insurance is not free - you have to pay a premium to obtain that insurance. Plus you have to know when the downturn will hit to know what tenor to use for your options. 1 month? 6 months? a year?