I headcanon that the Dinobots became “pregnant” with their babies before they were captured, but forced the sparklings into stasis as to not reveal them to Lockdown and birth them into such a dangerous environment that was the ship. It was after they were freed and had settled with the Autobots into the junkyard, that they felt safe and comfortable enough to nest and undo the stasis, allowing the sparklings to emerge.
This could also explain why Grimlock chose to fight against Optimus, but also surrender so quickly. If Optimus did cause any real damage, not only would Grimlock would be injured, but something horrible could’ve happened to his sparkling while it was still in his spark casing. Thus causing him to surrender after one blow as he realized what real danger the fight could’ve caused to his child.
They were actually so good at hiding the babies and their energy fields that the discovery wasn’t made until one day when Cade and the Autobots were standing around talking, and they saw a tiny triceratops waddle into their line of sight.