I've looked at most of the answers for related questions and they all speak about replacing parts that are old.
I just bought a new bike from a friend who rode the bike for about a month before leaving it in their garage for about 3 years only riding it on occasion.
When riding it home I came round a corner and was about to head up a slight hill. I shifted gears and the chain came off.
Yesterday I rode it to work and it was fine, but the chain keeps slipping whenever it is under reasonable load (such as going up hills).
I did some research and watched a few youtube videos. I also have a housemate who has been riding for years and we adjusted the derailleur this morning. But on my way to work this morning it still slips regularly. It is not slipping into another gear just crunching for a split second. It also changes gears without problem.
I looked at teeth on the gears and everything looks good as new. It is a 21 speed with Shimano gears.
Although everything is quite new could the chain be stretched just sitting in storage? What else should I be checking?
Update to cover some of the points in the answers:
The chain only came off once on the day I was riding it home after I purchased it. The chain is now just slipping. I think it came off due to the way I changed gears.
I'm not sure if the slipping is happening on the front or rear gear or as it goes through the derailleur
It's not my gear changing technique. At first I thought this may be the issue so I tried going easy on it yesterday and it still sleeps even if I have been in the same gear for 2 minutes before going up hill.
I have noticed it slips if I can't maintain the same pressure on the pedals. So if I slightly weaken the pressure for a second or pedal slightly slower it will slip.
There is no visible rust on the gears or the chain, but I will look at some of the other posts and see how to clean and lube the chain and will check this weekend to see if there are any stiff links. There is also no visible damage to any of the gear teeth, front or back. However the derailleur does look dirty.