Here are some simple situations. Imagine you go out and buy a share of Amalgamated Widgets for $100.
Tomorrow, Amalgamated Widgets files for bankruptcy. Your share is now worth nothing and will never be worth $100 again. You lose all your money.
Amalgamated Widgets is overvalued - it is fashionable, or there has been a speculative bubble, and the real value of the stock is around $50. Your share gently sinks back to this level and never really goes much higher. You lose $50 whenever you sell.
They have some bad years because people are buying fewer widgets. Your stock drops to $50 and doesn't recover for ten years. In year four, you crash your car and need to buy a new one, but all your money is tied up in long-term investments. You have to sell all your stock in a hurry. You run out of time to wait, and lose $50.
So you might lose because the share is not really worth as much as you pay for it - cases 1 & 2, where it may never get back to the $100 you bought it at. Or it might get back to the $100 - but you have to sell before then - case 3.
You can sit on shares for a very long time hoping that they will get back to a level that might be "profitable", and in reality we don't know if they ever will be. If you had bought bank shares in 2007, and hung onto them after the crash in 2008, you'd still be waiting for them to recover and turn a profit.