Why do my onions keep burning?
To clarify a little, there are several ways you can cook onions. 


You could be trying to get them to turn translucent. In which case, you can cook over medium heat, stirring frequently. This will take somewhere around 5 minutes. Preheating the pan isn't really required (especially if using a non-stick pan). If they start to brown, turn down the heat.
You could be trying to get them to turn translucent, with brown edges. Proceed as with translucent, but make sure to preheat the pan, and also use medium-high heat (but if they get too brown, turn down the heat).
You could be trying to caramelize them, turning them brown throughout. Cook them on low heat. At first, you can stir infrequently, but as they turn translucent and begin to brown, you'll have to speed up your stirring. This takes 30+ minutes.


So, if you were actually caramelizing onions, your heat was much too high.

In general, when something is browning too much (or outright burning) before the center is cooked, you need to turn down the heat or if only the pan-contact parts are browning then stir more frequently. To some extent when cooking in a pan, there is a trade-off you can make: low heat, infrequent stirring, long cooking time vs. high heat, constant stirring, quick cooking.