The answer to the first part of this question is pretty straightforward: Yes, stocks are able to lose all their value in the market. Now, we don't want to scare you off investing in stocks, or investing in general. However, we would be lying if we told you that stocks carry no risk (although some carry more than others).
To help you understand why a stock can lose all its value, we should review how stock price is determined. Specifically, the value of a stock is determined by the basic relationship between supply and demand. If a lot of people want a stock (demand is high), then the price will rise. If a lot of people don't want a stock (demand is low), then the price will fall. (For a deeper look into supply and demand and other economic concepts, check out our deep dive into the basics of Economics.)
If a stock's demand sinks dramatically, it will lose much (if not all) of its value. The main factor determining the demand for a stock is the quality of the company itself. If the company is fundamentally strong, that is, if it is generating positive income, its stock is less likely to lose value.
So, although stocks carry some risk, it would not be accurate to say that a loss in a stock's value is completely arbitrary. There are other factors that drive supply and demand for companies. (If you want to learn more, take a look at our guide on the basics of Stocks.)
The effects of a stock losing all its value will be different for a long position than for a short position. Someone holding a long position (owns the stock) is, of course, hoping the investment will appreciate. A drop in price to zero means the investor loses his or her entire investment – a return of -100%.
Conversely, a complete loss in a stock's value is the best possible scenario for an investor holding a short position in the stock. Because the stock is worthless, the investor holding a short position does not have to buy back the shares and return them to the lender (usually a broker), which means the short position gains a 100% return. Bear in mind that if you are uncertain about whether a stock is able to lose all its value, it is probably not advisable to engage in the advanced practice of short selling securities. Short selling is a speculative strategy and the downside risk of a short position is much greater than that of a long position.
To summarize, yes, a stock can lose its entire value. However, depending on the investor's position, the drop to worthlessness can be either good (short positions) or bad (long positions).