Frequently the trucks (the wheel/coupler assembly that sits under train cars) come unattached. Lionel trains from the 1970s and first half of the 1980s are especially prone to this, though other makes of trains aren’t immune either. And sometimes you just want to change the trucks–some Lionel and Marx O27 cars are just the right size for American Flyer S scale, for example, only the trucks are the wrong gauge.
It’s tempting to try to just re-attach them with a nut and bolt, but as the train runs in circles around the track, the nut loosens and eventually works its way out.
The key is all in the type of nut you use.
You need a stop nut (also known as a lock nut). A stop nut screws together with a bolt like an ordinary nut, but has a nylon insert that makes the screw highly resistant to backing out. You can get stop nuts at a good hardware store, but if you can’t find them at your local hardware store, Amazon (linked above) sells them in a quantity of 100 (which is likely to be a lifetime’s supply) for around $7. 6-32 is an ideal size.
Then, of course, you need a matching 6-32 machine screw. I use half-inch screws, as I find them long enough to reach through without having too much excess. 6-32 is a common size; it’s the same size screw used to hold computers together and to hold wall plates on light switches and electrical outlets. It’s likely you have some in your household jar of random screws; if not, any hardware store will have those, or you can order a box of 100 from Amazon for around $6.
If you have some on hand, put a pinhead-sized dab of PTFE grease on the top of the truck and on the head of the screw (opposite the side you drive) before assembly. This helps it to rotate more freely. It doesn’t take much, and modern synthetic grease will last decades in this application.
To attach the truck, simply line up the holes in the truck, car, and nut, then line up the screw and tighten it down. It’s easier on some types of cars than others. On a car with a deeply recessed hole, like a hopper, it’s helpful to hold the nut in place with a deep socket or a pair of needle-nose locking pliers to keep the nut from falling out while you’re trying to drive the screw. When attaching trucks to a Lionel 9013 hopper I bought from a train-store junk box for less than $10, I had to use needle-nose pliers and temporarily bond the screw to my screwdriver with a glob of Tacky Wax, a wondrous substance I’ve written about before. When a screw keeps falling off the head of your screwdriver because you have to hold it from anything but an ideal angle, a bit of Tacky Wax eliminates gravity from your list of enemies.
Tighten the screw down tightly enough that the truck doesn’t wobble, but leave it just loose enough that it turns freely. If you used grease, you’ll be able to tighten it down a lot. I usually find that if I tighten it down to the point that the truck doesn’t move, backing the screw out about 3/4 of a turn is about right. Too much wobble can cause derailments. I know of one hobbyist who drilled out the rivets holding together every train car he owns and replaced them with a machine screw and stop nuts, and he claims not to have had a derailment in years.
If you ever need to re-lube the truck, loosen the screw just enough that the tip of a toothpick can reach in, apply a pinhead-size dab of grease to the tip of a toothpick, then apply it between the truck and the car and re-tighten.