The Alien queen was in the exterior landing gear space of the Sulaco shuttle in Aliens. Even if she laid eggs on that exterior space, how did those eggs enter the shuttle? If two did, as many state, what would be the reason the eggs open on hibernating passengers? Aren't their triggers to open movement/proximity/noise as we've seen from Alien to Prometheus?
As far as I know, there is no official nor rational explanation for this given what we know about the circumstances. There was no time in which the queen could have laid the egg (or eggs) and she was too big to fit in the space where it were seen hatching. However, non-canonical materials may provide an explanation if so desired.
According to some of the early drafts for Alien 3, the aliens have a poorly-explained viral agent that can infect and transform foreign material into more aliens. This is similar to the black goo from the prequels Prometheus and Covenant and may have inspired its creation, with the notable exception that it can consume non-living and inorganic materials such as machines. I will refer to this agent as "black goo" for short, since the distinction between the two is purely academic. In these scripts, the queen left some black goo on Bishop from cutting him in half and the goo started consuming nearby materials to construct more aliens and/or eggs.
Furthermore, there is no reason to believe there are not more aspects of the alien life cycle that we have yet to learn about. The third party magazines Journal of the Travellers' Aid Society. Issue No. 4 and The Space Gamer #37 speculated on how the aliens might reproduce without a queen (having been published before the release of Aliens) and devised the explanation that adult aliens are capable of birthing small, maggot-like larvae that will mature into eggs if provided with sufficient food and space. Presumably the queen on the Sulaco managed to birth at least one or two such larvae that scurried away to safety while the queen distracted Ripley.
There is one obvious way those eggs could have gotten aboard the Sulaco, but it's not one most fans will want to consider.
Bishop could have brought them aboard. Remember that he was supposed to wait with the drop-ship while Ripley went to rescue Newt. But when she returned to the rendezvous point, he was gone. He returned shortly thereafter, explaining that the landing platform had been too shaky to remain on.
This leaves a good ten to fifteen minutes during which he was unaccounted for. He could have easily used that time to locate the hive, retrieve a couple of eggs, and stow them on the drop ship before returning to pick up Ripley.
This obviously makes Bishop a traitor, a fact that won't sit well with most fans of the franchise. But of course, he is Weyland-Yutani property. There's no reason he couldn't have been programmed with the same "crew expendable" bias as his predecessor on the Nostromo. In his defense, he might not have even been aware he was doing it.
The eggs didn't enter the shuttle, the spiders did. They could enter because even a hibernating body gives off life-sign infrared head and smells, so they entered by force and even acid burrowing into the shuttle like a scabies mite. The queen hitched a ride up through the atmosphere and 2000 degree ionosphere and troposphere and into space oxygen-less vacuum, this would trigger stress hormones in the creature which would have modified the eggs opening cuing triggers to open as soon as possible.
The aliens were from a home planet where even worse creatures exist, and the engineers used them and maybe modified their genetics to use them as bio weapons to destroy all life on other planets.