This problem is usually indicative of a bad connection at the battery (or one of the battery cables). It almost behaves like a resettable fuse. When there is a connection, the lights work because the connection is good enough to allow the little amount of power needed to power these devices. Then, when you try to start, the connection breaks because there is more demand than the connection can take and then nothing works ... wash, rinse, repeat.
To fix this, you need to figure out where the connection is getting lost. It may just take tightening a post on the battery. If the battery has a lot of corrosion at the posts, this could cause the condition. You'd need to clean the posts off and get a good connection again.
As @FredWilson suggests, the problem is most likely in the terminal where the cable attaches to the clamp. Loosen (but don't remove all the way) the bolts which holds the cable to the clamp, doing the negative first, then before reconnecting, work on the positive. Once done, reconnect the positive first then the negative last. This should prevent arcing. When the wire is out of it's holder, ensure the area of the clamp is clean to include any paint (specifically the red positive terminal). Then clean the cable, knocking any debris or corrosion out of the cable to get it as clean as possible. Once clean, coat the cable wires in dielectric grease and reattach firmly into the clamp. This procedure should most likely solve your issue. You can get dielectric grease at almost any parts store or I'd imagine Walmart as well.