Aside from equipment issues such as:
1. lose wheel bearings
2. wheels not dished
3. wheels severely out of true
4. lose headset bearings
5. mis-aligned frame
A bike will track perfectly straight. I've seen plenty of motorcycle races where the rider messes up and crashes. He falls off and the bike continues in a perfect straight line until it hits something.
Same thing on downhills; if you were to jump off the bike when it starts to wobble at 50mph, it will continue perfectly straight by itself. Couple of tips:
1. bend elbows and relax arms (more weight on front-end helps)
2. balance your weight on both hands evenly
3. shift weight forward or rearwards to dampen vibrations; typically leaning forward helps front-end wobble, rearward for rear-end wobble
The most important part is to relax and let the front-end shake a little when self-centering. If you lock the front-end with stiff-arms and a death-grip, when it hits a bump, it will steer sideways and give you the willies. If you relax the arms, the steering will get knocked to the side and immediately self-center due to the trail. It blips so fast, you hardly recognized what happened until after it's fixed itself.