Hey i have the chance to buy either one of those 2 bikes . which bike is better. Please help. thanks
It doesn't matter which is "better" in terms of componentry.
What matters is fit - you should try them out but sitting on them and adjusting saddle height. Then take a 2 minute ride up and down the road. This is normally enough to show you a poor fit immediately. If it feels wrong, it is wrong.
If you think the bike is good, take it on a longer ride, at least an hour. Try and get some up and downhill, and some straight+flat+fast, and a section of turns too. That should be enough to exercise and evaluate how it feels.
Answer Ride them and see which feels best.
Personally, the Giant looks newer, but the Trek look prettier with a more-horizontal top tube.
Very hard to discern which of the two used bikes is 'better' given just a picture of each. Having information on the year and component level would really help.
They both appear to be aluminium frames, If one has substantially better components, then it would be better.
However, you also need to look at the amount of wear each has, and if there are any problems such as wheels out of true. The primary wear items to look at are the tires, chain, rear sprocket cassette and front rings. If any of those are worn out you'll need to factor in replacing them.
As others have said, all other things being equal, how each fits you is a big deciding factor, Note that the Trek has its bars set quite high so those could come down if you wanted
One thing I can say with certainty is that they are actually slightly different types of bikes, The Trek X0 is a cyclocross bike with cantilever brakes, whereas the Giant Defy is a straight road bike.
The Trek will allow wider tires and could be a good 'go anywhere' bike that will take on unpaved and rougher paved trails. however, it may have classic cyclocross geometry with a higher bottom bracket which will place you higher on the bike, which you may or may not like.