In the original US cartoon (The Transformers), as you stated, Wheeljack is inspired to create them based on the discovery of dinosaur bones in the mountain the Ark is buried in. Initially aggressive & unreliable, the Dinobots are sealed away only to be reactivated later in the same episode, single-handedly retaking the Ark from the Decepticons.
In the Japanese cartoon, the Dinobots are called DinoForce and they're a Decepticon Combiner-Pretender group.
In the Marvel comics, the Dinobots were a special recon unit which was onboard the Ark with the other Autobots when it crashed, but they reactivated several million years before the other Autobots when the Ark was disturbed. Since the dominant lifeform on Earth at the time was dinosaurs, those were the forms they took. They later left the ark and were rediscovered by the other Autobots millions of years later after activation.
In the Dreamwave comics continuity, the Dinobots were a special recon unit sent to Earth to find out what happened to the Ark a million years earlier. After taking the dinosaur forms, they got tangled up with their Decepticon counterparts (the Insecticons) and ended up frozen in stasis until present day.
In the G.I.Joe vs. Transformers continuity, the Dinobots were a group of Autobots who were accidentally transported into Earth's prehistoric past by a malfunctioning Teletran I. When transported, Teletran also gave them the dinosaur forms as part of its stealth protocols.
I'm a big Gen1 guy, so I'm not too familiar with Beast Wars, Generation 2, etc. Also, the Dinobots will be in the upcoming movie Transformers 4: Age of Extinction, but I have no idea what their origins will be. Think of the most ludicrous, non-canon origin you can come up with and that will probably be close.