During refinement you discovered another design and went with that one instead of what you thought originally. It happens. That's what refinement is for. To add details to the backlog items, acceptance criteria, estimates, priorities, etc. If you discover better ways to add value to the product, or conditions change, or you get new insight into what youare building, then the user stories can of cource suffer changes. The product backlog is not fixed and is never complete.
This creates an extra work to update the stories based on that design.
It's not clear from your question, but by any chance did you create very detailed user stories based on the original design? You need to update the user stories based on the new designs, but how much is this "extra work"?
User stories should be short. It's "what" needs to be done. User stories are not software specifications where you detail the "how". If you decided on a new design, that normally shoudn't affect the "what". The "what" is the same even if the UI is different.
Now to your questions.
- What is the best time to start writing stories ?
There is no best time. All the time. Whenever needed. They are a way to organize the work you need to do, track it, take decisions about, discuss with others, show the result after they are implemented, etc. So whenever you know what you need, you can start writing the user stories. You can add details later. The stories at the top of the backlog are detailed enough to be able to do the work, but as you go down, stories become less detailed to the point they are just a placeholder to have a conversation about them and detail them when their turn comes to be implemented.
- Should we finalize the UI design first instead of writing stories ?
Depends on how much the design affects what you need to build. Do you need all of it to be finished before doing anything? Are there parts that are already known? Finalizing the design and writing stories are not necessarily exclusive to each other. Like I said, the product backlog evolves all the time. You might write some user stories now, some later, some are important now, some will become important later, some user stories will be more detailed, some less, etc.
- Is it fine to start working on stories after finalizing the UI design ?
You should have an idea of what needs to be done even if the UI design isn't finished. During refinement and sprint planning you will discuss details of how to implement each story. For that it's best to have the design finished so you don't come back and change your implementation if you get a new design. In Agile that won't be a problem, things change all the time. But it will be inneficient. It's better to have the design finished before starting work on implementation.
- Is there any suggestion which can be followed to avoid the similar issues in future ?
Collaboration and communication.
How do you as the PM interact with the development team? Do you give them work to do or are you all a team working on the same goals but with different roles and responsabiities? Giving people work has delays as one needs to define the work to be done then present them to who needs to do it, they give feedback, you make changes, then repeat. When you increase collaboration and communication these things still happen but the delays get reduced.