A second is defined (in the metric system) as a certain number of vibrations of a certain type of atomic clock signal. A year is define as a certain number of seconds.
When you hear that the most ancient stars imaged so far were formed around year 500 million, that's what the time interval "year" means. It does not refer to the orbit of this particular planet around the Sun, neither the Sun nor the Earth existed back in year 500 million.
You've heard of the CMB ("cosmic microwave background"). That's the most ancient light that astronomers are currently able to detect. It originated from glowing hot gas around year 380,000. That is, around 380,000 years after the start of expansion. And of course there were no stars back then and no planets orbiting them. That is not what "year" means.
Like I said, a year (for most of physics including early universe cosmology) is a certain number of atomic clock seconds. And cosmologists have to use a physical model to ESTIMATE the time it took for various things to happen, based on known physics. The basic model of expansion is called the Friedman equation. It's based on known physics (Einstein GR) and is checked and crosschecked every way people can think of. It brings us all the way up to the present and it gives a remarkably good fit to all the evidence so far.
But obviously nobody was back there with a quartz crystal wristwatch, or an atomic clock, timing everything. They have to time the processes they CAN observe and date, and leverage that back into the past using the best-fit equation model.
If you have more questions about this, keep on asking. There are other members who may come in and clear things up better than I can, and who have more detailed expertise, in some cases.