I removed the rear wheel and cleaned it using WD40 and then put it back on the bike and now the pedals move forwards and backwards. I tried putting the chain on one of the cogs and pushed the pedals forwards and then the chain went off the cogs and is now stuck between the cog and the frame (as it was before).
The brake pads and the wheel seem to be on a slight angle.
I don’t want to do anything to the bike in case I make matters worse.
Hang in there; and well done cleaning the bike.
Take off the wheel again and immediately reinstall it, lifting the chain onto the smallest sprocket. Make sure that the two ends of the axle lodge properly in the dropouts (slots pointing open downwards). Open the Quick Release (QR) lever and turn the knob on the other end clockwise till a little off tight (knob one side, lever the other). Fold the lever in which will tighten it all up. Now look and see that the wheel/tyre is centred on the seat tube (diagram in previous post for identification).
As I suggested upthread (in the post with the diagram of a rear derailleur), put the chain on the smallest sprocket (cog) and then, just for now, using a small screwdriver, turn the 'H' screw (see diagram in previous post - marked with an 'H')
one turn clockwise. This should stop the chain going off the sprocket when you turn the cranks forward.
I reckon nothing you do will make matters worse; push aside that concern. The only force needed is that to close the QR lever (should leave a 'dent' in your hand.